Hi everyone. I am currently embarking on a project with my team-mates, which requires us to build a robot on wheels which can track its way along a black strip (the path) without going off the black path. The rest of the area is white. The robot must also be able to climb up and down inclines.
We are to program the Arduino Uno on the robot to make it trace the black line path. The intended action for the robot is, if it leaves the black path completely, the wheels are supposed to reverse to put the robot back on path again, while, for minor path tracing errors, one wheel is supposed to turn faster than the other to make it shift left/right. The sensors are LDRs which give feedback to the Arduino Uno, while the LEDs supply the light source.
As this is an electrical engineering project, we used the following:
1x Breadboard
4x Light-Dependent Resistors (LDRs) with 220 Ohm fixed resistor in series
4x white LEDs with 10K Ohm fixed resistor in series
1x Arduino Uno board
1x LM324 (4 comparators in a chip like thing)
1x L293D (some H-bridge thing to drive the motors, with the ability to go forward and reverse by changing the voltage)
4x Variable Resistors (0-10K Ohms)
However, as of now, my robot has a huge problem which I am unable to diagnose. My robot kept moving in the reverse direction regardless of how I vary the resistance on the variable resistors or the LDRs by covering it (simulating black and white, i.e. low/high resistance).
I have attached my Arduino code and my project instruction sheet here for reference. The code, "Reverse" is the proper version of its predecessor.
I don't think there is anything wrong with the Arduino code as it seems correct. The weird thing is that the robot functioned somewhat normally when I coded it the direct opposite manner (i.e. all the "lows" and "highs" and vice versa) but when I replaced it with the corrected program, the wheels went in reverse direction regardless of any changes.
May I know how should I go about diagnosing the error, and if possible, advise me on the possible errors? If you need a photo of my robot, feel free to tell me.
Thank you very much.
Warmest Regards,
galaxy_twirl