This is my second robot, it is the same basic "cutting board" robot but now using the Sharp GP2Y0A02YK0F to avoid objects and walls. The code have comments and functions in portuguese like frente() = forward(), it was the way i found to undestand how to do it and to help other people from my country to understand it too. I think it is very basic code and if you have some advice to improve it .. it is welcome!
After testing i found that the values readed by the sensor have the following relation:
600 = 20 cm
500 = 35 cm
400 = 45 cm
So... changing that values in the code changes the distance that the robot stop when it detects an objetc.
That sensor have a good range , about 1.5 meter but that is not usable because the readings get very unstable.
The logic in the code makes the robot go ahead > stop when object is detected > turn head left > scan > if clear > turn left. If there is and obstacle in the left it scans to the rigth and if clear turns rigth. If there is obstacle in front, left and rigth it turns rigth again to try scape the trap. It always go back a little to make easy turning around.
Avoiding objects and walls
- Actuators / output devices: 3 servos
- Control method: autonomous
- CPU: Arduino Duemilanove
- Operating system: Arduino
- Power source: 4 AA batteries and 1 9 V batterie
- Programming language: Arduino
- Sensors / input devices: Sharp GP2Y0A02YK0F
- Target environment: Indoor or outdoor
This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/ir-sensor-robot