diff --git a/autonomousCar/autonomousCar.ino b/autonomousCar/autonomousCar.ino index 37c1700..41d19f3 100644 --- a/autonomousCar/autonomousCar.ino +++ b/autonomousCar/autonomousCar.ino @@ -53,6 +53,7 @@ /*Definition for turn time*/ #define TURN_TIME 800 +#define FORWARD_STEP 200 /* * ------------------------------------------------------- @@ -257,9 +258,9 @@ void moveCar(){ void park(int parkingNo) { int row = (parkingNo / 2) + 1; - int side = (parking % 2) //If side is 1 then the parking is to right + int side = (parkingNo % 2); //If side is 1 then the parking is to right // else if is 0 the parking is to left. - distance= getDistance(); //take the distance from ultrasonic sensor + distance = getDistance(); //take the distance from ultrasonic sensor while (row > 1) { absolute(255); @@ -273,6 +274,7 @@ void park(int parkingNo) { //Check the side value to turn. if (side == 1) { turnRight(255); + } else { turnLeft(255); } @@ -291,6 +293,9 @@ void park(int parkingNo) { int Serial_Input() { int number; + Serial.flush(); + while(!Serial.available()) ; + if (Serial.available() > 0) { number = Serial.parseInt(); while (number <= 0) { @@ -316,7 +321,6 @@ void loop() { //Serial.print("Distance: "); //Serial.println(distance); // Read serial input: - park(Serial_Input()); //delay(1000); // if (distance <15) {