From 04372c2590c886e2fffc4c72a7fa53876d3eadb2 Mon Sep 17 00:00:00 2001 From: cs161079 Date: Wed, 22 Jan 2020 03:23:30 +0200 Subject: [PATCH] Update v1.1 --- autonomousCar/autonomousCar.ino | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/autonomousCar/autonomousCar.ino b/autonomousCar/autonomousCar.ino index 3ae9d8f..371ac5f 100644 --- a/autonomousCar/autonomousCar.ino +++ b/autonomousCar/autonomousCar.ino @@ -92,11 +92,7 @@ void turnServo(int from, int deg){ } } -void serialFlush(){ - while(Serial.available() > 0) { - char t = Serial.read(); - } -} + /* * Setup Wiring Components */ @@ -125,6 +121,13 @@ void setup() { Serial.begin(9600); // Starts the serial communication } + +void serialFlush(){ + while(Serial.available() > 0) { + char t = Serial.read(); + } +} + /* * Stepper Function for Servo. * 1st Step: straight @@ -261,7 +264,7 @@ void moveCar(){ } void park(int parkingNo) { - int row = (parkingNo / 2) + 1; + int row = (parkingNo / 2); int side = (parkingNo % 2); //If side is 1 then the parking is to right // else if is 0 the parking is to left. @@ -294,7 +297,7 @@ int Serial_Input() { int number; - Serial.flush(); + while(!Serial.available()) ; if (Serial.available() > 0) {