- Power on
- Move forward crazy(full speed).
- speed depends the distance to the obstacle
- speed reduces to zero as it reaches towards the obstacle
- Once the gap in front has reduced to 8 cm(approx), stop and have a think about which way to turn
- Turn left or right - Turning right has a probability of 9/10 and turn left has a probability of 1/10.
- Once the decision has made on which direction to turn keep turning until the gap in front increases more than 8cm(approx).
- move forward
- got to step 2
int t=random(1,11); // randomly gets a value between 1 and 10, random() is an Arduino function
And from the previous version I have removed all the pause timings to make it more smooth-smooth. previously the minimum gap to brake was less than 8 cm. Increasing this minimum gap reduced the tank running into things and made the sensor more safe from collisions.
Now, these are my future improvement plans for this.
- Move the motor controller from the bread board into a PCB.
- Use a common 9V rechargeable battery for both Arduino and the motors. Currently Arduino runs with 9V PP3 battery and the motors on 4.8 V rechargeable battery pack.