From 0c6d78ab902373d654ca15643c324485cea068a6 Mon Sep 17 00:00:00 2001 From: cs161079 Date: Mon, 20 Jan 2020 14:17:47 +0200 Subject: [PATCH] Update v1.1 --- autonomousCar/autonomousCar.ino | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/autonomousCar/autonomousCar.ino b/autonomousCar/autonomousCar.ino index 1b67a78..37c1700 100644 --- a/autonomousCar/autonomousCar.ino +++ b/autonomousCar/autonomousCar.ino @@ -259,14 +259,15 @@ 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. + distance= getDistance(); //take the distance from ultrasonic sensor - while (row > 0) { + while (row > 1) { absolute(255); forward(); delay(FORWARD_STEP); motor_stop(); - r--; + row--; } //Check the side value to turn. @@ -278,11 +279,12 @@ void park(int parkingNo) { forward(); delay(TURN_TIME); motor_stop(); - - absolute(255); - forward(); - delay(400); + while(distance<10){ + absolute(255); + forward(); + } + motor_stop(); }