Arduino coding help... anyone?

jaden43129

Honorable
Dec 21, 2012
110
0
10,680
I have been trying to get this arduino turtle to detect walls in front of it then scan for the furthest wall and carry on to move towards it. I have 3 sensors, one in the front and two at about a 45 degree angle on the sides.

The problem is, once it detects the wall it'll step away from the wall but then once it turns around it'll move forwards an inch then stop moving and begins to scan even though there is no wall in front.

Here's the code:

https://shrib.com/JifP76ph6pH17kj

 


Well, can't say much until you state exactly what device you have and the sensors, but assuming IR distance sensors ("sharp sensors"), the voltage DECREASES as the object gets further away (or closer than minimum distance), so your forward sensor detection actually makes the device stop rather than go
Check the graph at https://www.pololu.com/product/136
 

jaden43129

Honorable
Dec 21, 2012
110
0
10,680


Yes, I'm using that type of sensor. I am also using the arduino romeo board.