• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

line follower

newbie1346

New Member
so i have a black line follower in the end of the field theres no black line only the white board so i want to make my robot go for 700 cm then turn right (90 degree turn)is't possible to code it in arduino without a sensor? and how do i do it?
 

Dr_Doggy

Well-Known Member
create a counter that counts when there is no line detected... reset when line is detected ... what is the velocity of robot so you can measure how long it takes to travel that 700cm and set the timeout accordingly
 

Pommie

Well-Known Member
Most Helpful Member
You need to use proper identifiers. What is 120/225?

Can you turn both motors on and if so, does it go in a straight line?

Mike.
 

newbie1346

New Member
125 is both motor speed and 225 is the maximum speed and yes i can turn both motors at the same time and it will go straight.
 

Pommie

Well-Known Member
Most Helpful Member
Then turn on both motors and time how long it takes to travel 700cm and write code to turn them on that long.

Mike.
 

Pommie

Well-Known Member
Most Helpful Member
Do the same again, turn one motor on forward and one backward, time how long it takes to do a full circle and use 1/4 of that time in your code.

You will probably need a short delay (0.25S) between the forward and turn code.

Mike.
 

newbie1346

New Member
sorry mike bit im nott good dith coding lets say it takes my robot 3 seconds to do 700cm if possible can you give a code exemple
 

Pommie

Well-Known Member
Most Helpful Member
Code:
//turn on both motors
delay(3000);                //3 second delay
//turn off motors
delay(250);
//turn on motors - one forward - one backward
delay(500);
Mike.
 

cowboybob

Well-Known Member
Most Helpful Member
so i have a black line follower ...
If you wrote the code for this portion of the program, I'm somewhat surprised you can't figure out the remainder (which is considerably easier) that you're asking for help with...
 

Pommie

Well-Known Member
Most Helpful Member
The 500 delay was just a guess as to how long it would take to turn 90 degrees.

Mike.
 

gophert

Well-Known Member
Most Helpful Member
You would need a final instruction after the last delay in Pommie 's code. You need an instruction to turn both motors off.
 

gophert

Well-Known Member
Most Helpful Member
How do you differentiate between an instruction and a comment in your code snippet? I assumed that the lines with hashtags were psudocode to say "do this here". If they are strictly comments that you planned on inserting into the code, your code is only a sequence of delays and will be as effective as my old boss.
 

Pommie

Well-Known Member
Most Helpful Member
How do you differentiate between an instruction and a comment in your code snippet? I assumed that the lines with hashtags were psudocode to say "do this here". If they are strictly comments that you planned on inserting into the code, your code is only a sequence of delays and will be as effective as my old boss.
Well, it's obviously C code. However, I've known a few people like your old boss?

Mike.
 

Latest threads

EE World Online Articles

Loading

 
Top