|
@ -259,14 +259,15 @@ void park(int parkingNo) { |
|
|
int row = (parkingNo / 2) + 1; |
|
|
int row = (parkingNo / 2) + 1; |
|
|
int side = (parking % 2) //If side is 1 then the parking is to right
|
|
|
int side = (parking % 2) //If side is 1 then the parking is to right
|
|
|
// else if is 0 the parking is to left.
|
|
|
// else if is 0 the parking is to left.
|
|
|
|
|
|
distance= getDistance(); //take the distance from ultrasonic sensor
|
|
|
|
|
|
|
|
|
while (row > 0) { |
|
|
while (row > 1) { |
|
|
absolute(255); |
|
|
absolute(255); |
|
|
forward(); |
|
|
forward(); |
|
|
delay(FORWARD_STEP); |
|
|
delay(FORWARD_STEP); |
|
|
motor_stop(); |
|
|
motor_stop(); |
|
|
|
|
|
|
|
|
r--; |
|
|
row--; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Check the side value to turn.
|
|
|
//Check the side value to turn.
|
|
@ -278,11 +279,12 @@ void park(int parkingNo) { |
|
|
forward(); |
|
|
forward(); |
|
|
delay(TURN_TIME); |
|
|
delay(TURN_TIME); |
|
|
motor_stop(); |
|
|
motor_stop(); |
|
|
|
|
|
|
|
|
absolute(255); |
|
|
|
|
|
forward(); |
|
|
|
|
|
|
|
|
|
|
|
delay(400); |
|
|
while(distance<10){ |
|
|
|
|
|
absolute(255); |
|
|
|
|
|
forward(); |
|
|
|
|
|
} |
|
|
|
|
|
motor_stop(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|