Continue to Site

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

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

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

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.

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.

Then turn on both motors and time how long it takes to travel 700cm and write code to turn them on that long.

Mike.

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

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.

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

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.

can you explain the last line please

Mike.

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

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

The 500 delay was just a guess as to how long it would take to turn 90 degrees.

Mike.

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

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.

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.

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.

Status
Not open for further replies.