How to make a LINE FOLLOWING WITH OBSTACLE AVOIDING ROBOT/ ARDUINO LINE FOLLOWING ROBOT/ smart robot
HTML-код
- Опубликовано: 2 окт 2024
- In this video, we will learn how to make a 4 wheel drive line following robot with obstacle avoidance using arduino .
Codes & diagram: drive.google.c...
PREVIOUS VIDEOS
LINE FOLLOWING ROBOT • How to make a LINE FOL...
ARDUINO BLUETOOTH CONTROLLED CAR • How to make a Smartpho...
AUTOMATIC WATER TAP • HOW TO MAKE A AUTOMATI...
AUTOMATIC SOAP DISPENSER • How to make AUTOMATIC...
can it work with only two motors and wheels?
Hassan Arif yes it will work with 2 wheels
Thanks i tried and it works. Although i must say that the code had a few extra things which were not needed at all (at-least not in my case) so i made a few modifications to the code and now it works like a charm :)
*Thanks Again*
Excuse me, if it is possible could you please send me the edited code ( in the comment section here)
Well i edited the code for only two motors at first, but later on i added two more motors for which the code provided by makerQ worked perfectly. All i edited in the code was the delay timings, and deleted a while loop, not any other major modification that i can remember, but unfortunately i don't have that code anymore, but if you can tell me the problem you're facing with this code i might be able to help.
So the thing that is happening is that my wheels are continuously moving backwards, unable to follow a line, and unable to avoid obstacles, what I did was that I just removed the while loop from the code giving me this:
#include //Ultrasonic sensor function library. You must install this library
int vSpeed = 110;
int turn_speed = 230; // 0 - 255 max
int t_p_speed = 125;
int stop_distance = 12;
int turn_delay = 10;
//HC-SR04 Sensor connection
const int trigPin = 11;
const int echoPin = 12;
//L293 Connection
const int motorA1 = 3;
const int motorA2 = 4;
const int motorAspeed = 5;
const int motorB1 = 7;
const int motorB2 = 8;
const int motorBspeed = 6;
//Sensor Connection
const int left_sensor_pin =9;
const int right_sensor_pin =10;
int turnspeed;
int left_sensor_state;
int right_sensor_state;
long duration;
int distance;
void setup() {
pinMode(motorA1, OUTPUT);
pinMode(motorA2, OUTPUT);
pinMode(motorB1, OUTPUT);
pinMode(motorB2, OUTPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
delay(3000);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance= duration*0.034/2;
Serial.print("Distance: ");
Serial.println(distance);
left_sensor_state = digitalRead(left_sensor_pin);
right_sensor_state = digitalRead(right_sensor_pin);
if(right_sensor_state == HIGH && left_sensor_state == LOW)
{
Serial.println("turning right");
digitalWrite (motorA1,LOW);
digitalWrite(motorA2,HIGH);
digitalWrite (motorB1,LOW);
digitalWrite(motorB2,HIGH);
analogWrite (motorAspeed, vSpeed);
analogWrite (motorBspeed, turn_speed);
}
if(right_sensor_state == LOW && left_sensor_state == HIGH)
{
Serial.println("turning left");
digitalWrite (motorA1,HIGH);
digitalWrite(motorA2,LOW);
digitalWrite (motorB1,HIGH);
digitalWrite(motorB2,LOW);
analogWrite (motorAspeed, turn_speed);
analogWrite (motorBspeed, vSpeed);
delay(turn_delay);
}
if(right_sensor_state == LOW && left_sensor_state == LOW)
{
Serial.println("going forward");
digitalWrite (motorA1,LOW);
digitalWrite(motorA2,HIGH);
digitalWrite (motorB1,HIGH);
digitalWrite(motorB2,LOW);
analogWrite (motorAspeed, vSpeed);
analogWrite (motorBspeed, vSpeed);
delay(turn_delay);
}
if(right_sensor_state == HIGH && left_sensor_state == HIGH)
{
Serial.println("stop");
analogWrite (motorAspeed, 0);
analogWrite (motorBspeed, 0);
while(true){
}
}
if(distance < stop_distance)
{
digitalWrite (motorA1,HIGH);
digitalWrite(motorA2,LOW);
digitalWrite (motorB1,LOW);
digitalWrite(motorB2,HIGH);
delay(250);
analogWrite (motorAspeed, 0);
analogWrite (motorBspeed, 0);
delay(500);
digitalWrite (motorA1,HIGH);
digitalWrite(motorA2,LOW);
digitalWrite (motorB1,HIGH);
digitalWrite(motorB2,LOW);
analogWrite (motorAspeed, t_p_speed);
analogWrite (motorBspeed, t_p_speed);
delay(900);
digitalWrite (motorA1,LOW);
digitalWrite(motorA2,HIGH);
digitalWrite (motorB1,HIGH);
digitalWrite(motorB2,LOW);
analogWrite (motorAspeed, t_p_speed);
analogWrite (motorBspeed, t_p_speed);
delay(800);
digitalWrite (motorA1,LOW);
digitalWrite(motorA2,HIGH);
digitalWrite (motorB1,LOW);
digitalWrite(motorB2,HIGH);
delay(900);
digitalWrite (motorA1,LOW);
digitalWrite(motorA2,HIGH);
digitalWrite (motorB1,HIGH);
digitalWrite(motorB2,LOW);
delay(700);
digitalWrite (motorA1,LOW);
digitalWrite(motorA2,HIGH);
digitalWrite (motorB1,LOW);
digitalWrite(motorB2,HIGH);
delay(650);
digitalWrite (motorA1,LOW);
digitalWrite(motorA2,HIGH);
digitalWrite (motorB1,HIGH);
digitalWrite(motorB2,LOW);
left_sensor_state == HIGH;
while(left_sensor_state == LOW){
left_sensor_state = digitalRead(left_sensor_pin);
right_sensor_state = digitalRead(right_sensor_pin);
Serial.println("in the first while");
}
digitalWrite (motorA1,HIGH);
digitalWrite(motorA2,LOW);
digitalWrite (motorB1,LOW);
digitalWrite(motorB2,HIGH);
delay(100);
digitalWrite (motorA1,HIGH);
digitalWrite(motorA2,LOW);
digitalWrite (motorB1,HIGH);
digitalWrite(motorB2,LOW);
delay (500);
}
}
void loop() {
}
But what's happening is that the motors/wheels continuously move backwards, unable to do anything else. Please help and thank you for the kind reply!
The while loop will stop the car , it is used to stop at the end, if your car is not moving delete that while loop
MAKER Q
I want a coad now pls
I'm using arduino uno for this project but the robot won't run at all, you said you have to delete the while loop first but I don't know where the while loop is, please show me 🙏🙏
If it's not working delete the while loop in the code and try again
Bhai code ka link open kiya to no preview available aa raha h kya karr
which is the while loop to be deleted
bro what is the battery used ?i m using RS.20 9v battery but its not working?
i have problem with code/.... can you help me
are you sure the code is correct
The code is not appearing... plz send this code.. sr...
super, excellent
just wow.
What kind of battery I can use instead of 18650 battery plz tell me sir
Arduino nano programing not open in to the description please give me the programing
Very well made
kadak re bhava
can you plz send the code i need to make some thing similar for school and it whould help a lot
thank u
sir kya hum iss project me arduino uno use kr sakte hai kya with l298n and isake connection kaise rahenge with arduino uno.
Worst video at all... Sala 1 month lag gya nhi ho rha
Bro ith malayalathil oru vdo cheyyoo plzzzzx
Sir please give me the Arduino nano programing
Which battteries do you use
Please tell while loop wala portion kitna tak delete karna hoga please
my motors are not moving.please help me
bro motos are not rotating???
Can we use Arduino Uno instead of nano
1:25 Thnx i need this only 💗
Where we want to delete while loop in the code
Hello
Sir the car is not moving just upload the edited program or plz mail it to me i need it for my ptoject plz reply soon as soon possible i am waiting...........
you done yet?
@@nguyenthanhhoan4223 yup lol its been year now
Please make same project using Arduino Uno
Is it the same with arduino uno
can it be made with python?
i have been trying for 2 days to recreate it with python and rpi but no luck
do you have the same code using raspberry ?
Can i use a 12v battery
Can you provide for l298d with program . I was typing to change your program but I cannot make.
sir i want to make all in one .bluetooth controlled +line following + obstacle avoidance ..please help in code or make a video of all in one ..
You just have to buy a bluetooth module, connect it to the arduino, compile a bluetooth app to control the car. After all that, compile a code for the arduino so that the bluetooth module on the car can give orders to the arduino board that controls the car
This the code updated?
what we can write in behalf of c/cc+ which is written in code
Is their any code to do this
Plzz tell if it is working so I can make my science model
Can i use arduino uno?
What weight bear this car
Please PARTS USED dc motor's and wheel's Arduino nano Motor driver l298n IR SENSOR can you send me a web site on Amazon?
Conection Digram
U dont have Instagram?
I'm using arduino uno for this project but the robot won't run at all, you said you have to delete the while loop first but I don't know where the while loop is, please show me 🙏🙏
can you give the code for arduino uno
Yeah I can't afford arduino nano
Coding link is not working please make again.
hi MAKER Q
i'm using adafruit motor shield can you give me the program for that plsplspslspls
i have school exhibition
Can I know the circuit diagram with pro mini aurdino
Without any programming circuit led is on or not
it will be on , if power is supplied
Sir i am student and making line following many error is occuring please help
sir your attachment code is not open .Why?plz help me
Can you please make the robot with arduino uno
Nice brain
brother my ardioino is showing port com 3
How many total expensive bro
Can you explain me what to do when only the obstacle avoidance works and the line follower doesn't works
Can you pls send me the code for only two motors pls
reply brooooooooooo if obstacle is there again after turning left, what to do?
Sir can you send me the code plzzzzzzzzzzzzzzzzzzzzz
any idea how to fix a problem where only the front left and back left wheels are working.
it's not working please help me.
Is the output of the ir sensor is low or high?? Please answer..
Can we add Bluetooth to it then send to me circuit diagrams please send me the code
the code is error....why?? expected initializer void
can you let me know if it drives in revers after completing the line in to point b and ten it comes back to point a in a line with obstacles.
can i erase the old program of line following and use this new given program
the code is unspportive....what should I do?
Sir error occurred
Of problem uploding to board
How can i get the items
I have this line follower code
Sir what is the rpm of the motor
The code is not appearing
Can you send me the code,please?
Can we use arudino uno insted of arudino nano
Sir...,How I can use Pid Control for this car...?
what i have to do it not moving😭
love you sir...we went more cool project from you sir..
can it work with arduino uno r3?
Thắng Huy Yes
xe chạy được chưa bro ơi.
Sir can I use Arduino Uno
Nan robotics und pakshe corono aayathukond nadannilla nan colour sorter aake cheythu
Can we use arduino uno instead of arduino nano
Can you do with arduino uno plrase
what are materials for this project? need asap
In place of Arduino Uno can I use Arduino nano
codes for two wheels only please
Where we have to write 'if' in the delay to come to line?
Your code are not working
can u explain the working
Will the cose work with ardiuno uno
It's not working
is it work with power bank?
Can I use arduino uno instead of arduino nano?
Amazing you are mind-blowing
I want a code pls
Code is not working
Coding is not opening
this robo is very easy made
hello! I made it. but, It's not following line and also not detecting obstacles. just moving in different directions. can you please help me!
you done yet?
Sir I want to stop the robot when there is obstacles how to do that , please share another code for that please please please 🙏
Please share this code without rotating it
Can you plz share the list of all components required for this whole project and even the program we have a project based on this!
Please sir
Nice
While compiling code through mobile application ArduinoDroid it says error
What should I do
Maybe the library in which you're compiling the code ?
how can i get the code
the code is not working
Wau 😍😍😍