Line tracking with arduino

hi,i start to use arduino and i wanna a project with arduino..Could you please help me to write a line tracking code with arduino?

Well, now, that would all depend on what you were going to move along the line, and how you were going to sense where the line is.

Some of us could write the code,if we had a few more details.

Line following by what means?

Color/brightness sensor?
Camera?
:slight_smile:

sorry about the insufficient informotion.
my robot track the black line on the white area or (table),also I use IR sensor([ch305]nfrared) to sense the color.sensor datasheet is that http://www.lynxmotion.com/images/data/tra.pdf
but i am the new user of the arduino therefore could you please help me to write(software) the code of this program

So, now we know that you have a robot, and a sensor that can detect a line. We still don't know if your robot rolls, walks, hops, or slithers. We also don't know what makes it roll, walk, hop, or slither in any specific direction.

Are you using servos to control direction? Do you have motors that control forward/reverse motion? What kind?

sorry sorry :slight_smile:
i use two dc motor to conroll the wheels..i do not use servo,i use just two dc motor..i wanna control the motors with H bridge..i hope these informations are sufficient to help me..thanks a lot for your help

So, start simple.
Don't expect to write one sketch that will do everything from day one.
Break down the problem.
Work out how to connect your H-bridge, and then write simple routines to start, stop and reverse the motors.
Check these out on your robot chassis.
Make sure that you can control the speed too.

Then check that you can make sense of the readings back from the line sensor. You may need to calibrate this for your particular course.

Have a look around the playground.

hi, can you give me some arduino code(software code)example of the solution of the my problem?thank you

No, of course not!
We don't know what the geometry of your robot is, its mass and motor performance or how it is wired.

There'd be no fun for you if we gave you the answers. :o

slithers

I want one :slight_smile:

slithers

Hi apranax
I presume you are using a wheeled robot perhaps 2 wheels and 1 castor wheel and that the sensors are mounted on the front and that you are trying to follow a black line on a white surface. Given this, here is the logic(no code, you'll have to do some hard work)

Sense all the three inputs from the sensor(left, middle, right) using analog read. now whichever sensor is on the black surface, will give a low and the others an high. So you will have nine possible combinations. First workout the actions for these combinations(there are four actions possible - go straight, stop, go left and go right). Run the combinations through a switch case and perform the actions.
performing the actions would mean controlling the 2 dc motors. any 1 of these motors running forward with the other running backwards will produce a turn in the direction of the motor running forward. so wire up the dc motors to the h-bridge and send output to the h-bridge from 4 digital pins on the arduino. things to remember - you would need to provide a separate power source(depending upon you motor requirements) for the h-bridge with a common ground to the arduino. intially you might not want to drive their motors at their full voltage ratings(they might be too fast and you might miss the line!)

Hope you can do the coding with this.

Cheers,
pracas