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) {