|
|
@ -52,8 +52,8 @@ |
|
|
|
#define SERVOPIN 6 |
|
|
|
|
|
|
|
/*Definition for turn time*/ |
|
|
|
#define TURN_TIME 800 |
|
|
|
#define FORWARD_STEP 200 |
|
|
|
#define TURN_TIME 2000 |
|
|
|
#define FORWARD_STEP 500 |
|
|
|
|
|
|
|
/*
|
|
|
|
* ------------------------------------------------------- |
|
|
@ -114,9 +114,8 @@ void setup() { |
|
|
|
pos = 1; |
|
|
|
dir = 1; |
|
|
|
|
|
|
|
//Initialize car direction and make walk
|
|
|
|
absolute(MAX_WHEEL_SPEED); |
|
|
|
forward(); |
|
|
|
//Initialize car engine in sleep mode
|
|
|
|
motor_stop(); |
|
|
|
|
|
|
|
Serial.begin(9600); // Starts the serial communication
|
|
|
|
} |
|
|
@ -260,16 +259,11 @@ void park(int parkingNo) { |
|
|
|
int row = (parkingNo / 2) + 1; |
|
|
|
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
|
|
|
|
|
|
|
|
while (row > 1) { |
|
|
|
absolute(255); |
|
|
|
forward(); |
|
|
|
delay(FORWARD_STEP); |
|
|
|
motor_stop(); |
|
|
|
|
|
|
|
row--; |
|
|
|
} |
|
|
|
absolute(255); |
|
|
|
forward(); |
|
|
|
delay(row*FORWARD_STEP); |
|
|
|
motor_stop(); |
|
|
|
|
|
|
|
//Check the side value to turn.
|
|
|
|
if (side == 1) { |
|
|
@ -280,11 +274,12 @@ void park(int parkingNo) { |
|
|
|
} |
|
|
|
forward(); |
|
|
|
delay(TURN_TIME); |
|
|
|
motor_stop(); |
|
|
|
|
|
|
|
while(distance<10){ |
|
|
|
absolute(255); |
|
|
|
|
|
|
|
while(getDistance()>10){ |
|
|
|
absolute(255); |
|
|
|
forward(); |
|
|
|
forward(); |
|
|
|
delay(300); |
|
|
|
} |
|
|
|
motor_stop(); |
|
|
|
} |
|
|
@ -302,8 +297,8 @@ int Serial_Input() |
|
|
|
while (number <= 0) { |
|
|
|
// convert the incoming byte to a char and add it to the string:
|
|
|
|
number = Serial.parseInt(); |
|
|
|
Serial.print("Value:"); |
|
|
|
Serial.println(number); |
|
|
|
//Serial.print("Value:");
|
|
|
|
//Serial.println(number);
|
|
|
|
// clear the string for new input:
|
|
|
|
} |
|
|
|
// if you get a newline, print the string, then the string's value:
|
|
|
|