Assistance Required on a Robot project with Arduino Uno

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

Can't see your code or other sheet you've attached. Would be interested in seeing a picture of your robot.

My robot kept moving in the reverse direction

. Try giving the motor driver the "move forward" command.

It's much more reliable to use IR emitters and photo transistors . Because the robot gets more accurate . Normal LDRs are not the best choice as the rooms light might cause problems .

galaxy_twirl:
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.

Your bot is probably a Line follower bot.
"Lows and Highs" you refer to, depend on how you connect the motor. If you interchange the wires(at the terminals of you motor) it''ll move forward so it's not a problem.

let me explain this with an example-
Your motor has 2 terminals - terminal A and terminal B .
Connect 'A' to positive terminal(HIGH) and 'B' to negative terminal(LOW) of a battery. Lets assume it turns in clockwise direction.
Now connect 'A' to negative (LOW) and 'B' to positive (HIGH) terminal.It'll turn in anticlockwise direction.

Now in your case , if your Forward condition(programming part) is making your robot move in reverse direction then Simply interchange the connections at the motor terminal and run the bot. It'll move forward.

Things you need to be careful -

1.Line followers won't work in bright places (lot of sunlight) efficiently and this may interfere with the mobility of your bot.

  1. Make sure the black Strip is really dark , coz this is supposed to absorb the light emitted from leds while white reflects it

I don't see any code uploaded