# line follower

Status
Not open for further replies.

#### 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

#### newbie1346

##### New Member
First of all tvank you for your ansewer ,lets say the velocity is arround 120/225 how can i code it exactly

#### Pommie

##### Well-Known 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
Then turn on both motors and time how long it takes to travel 700cm and write code to turn them on that long.

Mike.

#### newbie1346

##### New Member
and what about the 90 degree angle after the 700 cm i'm strugeling with the coding here

#### Pommie

##### Well-Known 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
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.

#### newbie1346

##### New Member
can you explain the last line please

Mike.

#### cowboybob

##### Well-Known 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...

#### newbie1346

##### New Member
all i want to know is why did you put 500 delay thats all

#### Pommie

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

Mike.

#### gophert

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

#### Pommie

##### Well-Known Member
You would need a final instruction after the last delay in Pommie 's code. You need an instruction to turn both motors off.
Actually just a final comment as I've no idea how to turn motors on or off.

Mike.

#### gophert

##### Well-Known 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.