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