Browse Source

Update v1.2

master
Evangelos Oulis 5 years ago
parent
commit
a492573936
  1. 55
      autonomousCar/autonomousCar.ino

55
autonomousCar/autonomousCar.ino

@ -255,38 +255,57 @@ void moveCar(){
}
}
void park() {
void park(int parkingNo) {
int row = (parkingNo / 2) + 1;
int side = (parking % 2) //If side is 1 then the parking is to right
// else if is 0 the parking is to left.
while (row > 0) {
absolute(255);
forward();
delay(FORWARD_STEP);
motor_stop();
r--;
}
//Check the side value to turn.
if (side == 1) {
turnRight(255);
else {
turnLeft(255);
}
forward();
delay(TURN_TIME);
absolute(255);
motor_stop();
absolute(255);
forward();
delay(400);
}
String inString;
void Serial_Input()
{
while (Serial.available() > 0) {
int inChar = Serial.read();
if (isDigit(inChar)) {
int Serial_Input()
{
int number;
if (Serial.available() > 0) {
number = Serial.parseInt();
while (number <= 0) {
// convert the incoming byte to a char and add it to the string:
inString += (char)inChar;
number = Serial.parseInt();
}
// if you get a newline, print the string, then the string's value:
if (inChar == '\n') {
Serial.print("Value:");
Serial.println(inString.toInt());
Serial.print("String: ");
Serial.println(inString);
Serial.println(number);
// clear the string for new input:
inString = "";
}
}
}
return number;
}
void loop() {
// Calculating the distance
//distance= getDistance();
@ -295,8 +314,8 @@ void loop() {
//Serial.print("Distance: ");
//Serial.println(distance);
// Read serial input:
Serial_Input();
park();
park(Serial_Input());
//delay(1000);
// if (distance <15) {
// // Change direction to motors

Loading…
Cancel
Save