Easy Line Following Robot with Arduino!
HTML-код
- Опубликовано: 2 окт 2024
- Get your kit here:
www.banggood.c...
Get started with Arduino with this kit:
www.banggood.c...
Get your Arduino Uno ($3):
www.banggood.c...
Get your Arduino Nano ($1):
www.banggood.c...
You can get the L293D module here:
www.banggood.c...
This is a tutorial on how to build a line following robot using Arduino. The line followr robot is of different
configurations, so in this build, I teach how to make the simplest and the easiest line following robot.
This build uses the L293 Motor driver module shield to build the line follower robot, which makes it an easy build.
The coding and sketch for the line following Robot is also explained in detail.
Always wanted to learn how to make a line following robot with arduino? Interested in a DIY Project for arduino? This is the video for you!
If you liked this simple DIY Project, please subscribe to Fungineers for more DIY, Arduino, 3D printing projects.
Keep fungineering!
Heres' the code guys:
#include
AF_DCMotor motorA(4); //this is the left motor
AF_DCMotor motorB(2); //this is the right motor
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Line Follower Rover");
delay(500);
pinMode(A0, INPUT); // declare A0 as input pin for left sensor
pinMode(A1, INPUT); // declare A1 as input pin for right sensor
motorA.setSpeed(180); // turn on motor1
motorA.run(RELEASE);
motorB.setSpeed(180); // turn on motor2
motorB.run(RELEASE);
}
void loop() {
int sensor1 = digitalRead(A1);
int sensor2 = digitalRead(A0);
//Reading the values of the sensors on the serial monitor
Serial.print(sensor1);
Serial.print(" ");
Serial.println(sensor2);
delay(50);
//value of 0 means no black line, value of 1 means black line detected.
//Move forward if both sensors zero (no black line).
if ((sensor1 == 1) && (sensor2 == 1))
{
motorA.setSpeed(200); // turn on motor1
motorB.setSpeed(200);
motorA.run(FORWARD);
motorB.run(FORWARD);
}
//Turn left if left sensor (sensor 1) detects black line
else if ((sensor1 == 0) && (sensor2 == 1))
//motor1 is left motor, motor 2 is right motor
{
motorA.setSpeed(200); // turn on motor1
motorA.run(FORWARD);
motorB.setSpeed(50);
motorB.run(FORWARD);
}
//Turn right if right sensor detects black line
else if ((sensor2 == 0) && (sensor1 == 1))
//motor1 is left motor, motor 2 is right motor
{
motorA.setSpeed(50); // turn on motor1
motorA.run(FORWARD);
motorB.setSpeed(200);
motorB.run(FORWARD);
}
}
when i use the code it tells me afmotorh: no such file or directly plz help
You have to add the afmotor library to your libraries folder
where can i find afmotor library
Google it man.
Best answer ever......... You already gave the code what more do they want, for you to do it for them.
Your path is too wide bro
how did you use two power supplies
Hi teacher i have a problem in my project please make a vedio about using l293d motor driver with fire sensor and servo.
How volt does it need
Can u plz make videos on how to control a robot car by MEMS sensor??
Perfect
uhm, where are the double A batteries connected??? the 5v was the only one explained where to connect in the motor driver
Hey! Im a beginner. I bought chasis the man there handed me chasis connected with 4 wheels and 4 DC motos now I don't understand the connection for 4 motors and code too. I m thinking to just get some wholes on any tough plastic at home and make my own? plz let me know about the connection else I can make a new chasis. Im confused.
I have a IR sensor array which has ports like, "VCC,GND,S1,S2,S3,S4,S5,CLP,Near". How can I connect it? I am facing problem in connection. Can you please help me out? Can I have your facebook ID or anything so that I can directly contact with you?
You can conenct 5V to Vcc, ground to GND, and sensors to S1 S2,etc..
shows stray error
Found the solution
Soon will be uploading on my channel...
How can i build a line following robot for multiple paths detection
Can you make this project for 4 motors instead of 2? please
can
How do you make a robot turn on a straight line ??
sir may you send me the link of the program
cn i use hiwat 9v battery of 20 rs
Is it just me or does the "//" explanation not quite add up, because if your car steers to the right and you increase the speed of the left wheel and decrease the speed of the right wheel, won't the car keep steering to the right?
Yeah
@@Fungineers Thanks! This helps a lot for someone with zero knowledge about coding
The right motor was bad. It spun slower than the left motor even when same voltage was applied. Thats the reason the car is always pulling to one side but the arduino is correcting it continously. So make sure you get good Motors :)
Good job
Sir.. thanks for your videos. I got 1 questions if you can answer. 1) can we used different motor driver such as l29d instead of this?
I suppose you wanted the write l293d. The answer is yes you can use the l293d, l293b, l298n, or any other motor driver but you need to look datasheet for connection and code. Because codes are changing with components.