Photovore bot > WIP
July 19, 2009
Rigged up something if it can be called a bot. Two LDRs provide sensor information. Intially, i set up the code so that if one sensor got more light, then the opposite wheel would turn forward and the other wheel backward. This turned out to be extremely jerky, with the thing acting like an epileptic loony. Hence, after continuous research on pwm, i've tried a different approach. Sensor values are read and if one gets more light, the opposite wheel turns with a pwm pulse propotional to that sensor reading, while the other wheel turns at a slower rate, determined by the opposite sensor.
heres some pseudo code to clarify...
1. Read left and right sensors
2. If left > right, then
a. speed of right motor = pwm value based on left sensor reading..ie right turns faster
b. speed of left motor = pwm value based on (right sensor reading / 2) ... ie left turns much slower
3. if right > left, then exact opposite of above
4. if right and left almost equal, then turn both motors at same speed
I also tried completely halting one motor while the other turned, to change direction but i thought this was smoother. Perhaps there are far better methods...
specs: Arduino, 6v battery, two 12v gear motors, two LDRs.
If anyone has spare time , perhaps they could be gracious enough to glance at the rudimentary code (attached as htm file for greater readability)??
PS > wall banging video attached...