Arduino Robot Car | Obstacle Avoiding Robot Car 2WD with Ultrasonic sensor and L298N Module

preview_player
Показать описание
#arduino_car, #arduino_robot, #obstacle_avoiding_robot

- Arduino Obstacle Avoiding Robot Car 2WD Kit:
1 x Car chassis
2 x Car Wheels
2 x DC Gear Motor
2 x 20 line code disk
4 x Fasteners (high intensity black acrylic)
1 x Caster
1 x Four battery box
1 x Quality Rocker Switch
1 x V5 shield
1 x UNO R3
1 x SG90
1 x FPV
1 x L298N

- Wiring diagram and Arduino Sketch:

- Music:
JJD - Sugar High Listen to the track here -

ALWAYS WITH YOU – COLBREAKZ & LOXIVE Listen to it on Spotify here:

APHRODITE – NEPTUNICA
Рекомендации по теме
Комментарии
Автор

BROTHER YOUR CODE IS SHOWING ERROR PLZ HELP AND SEND CODE AGAIN
PLZ PZLPZLZPZLZPZLZ

SarimXhan
Автор

This is the correct code:
#include <Servo.h>

Servo servo;

const int trigPin = 13;
const int echoPin = 12;

const int servoPin = 11;

const int enAPin = 6;
const int in1Pin = 7;
const int in2Pin = 5;
const int in3Pin = 4;
const int in4Pin = 2;
const int enBPin = 3;

enum Motor { LEFT, RIGHT };

void go(enum Motor m, int speed)
{
digitalWrite(m == LEFT ? in1Pin : in3Pin, speed > 0 ? HIGH : LOW);
digitalWrite(m == LEFT ? in2Pin : in4Pin, speed <= 0 ? HIGH : LOW);
analogWrite(m == LEFT ? enAPin : enBPin, speed < 0 ? -speed : speed);
}

void testMotors()
{
static int speed[8] = {128, 255, 128, 0, -128, -255, -128, 0};
go(RIGHT, 0);
for (unsigned char i = 0; i < 8; i++)
go(LEFT, speed[i]), delay(200);
for (unsigned char i = 0; i < 8; i++)
go(RIGHT, speed[i]), delay(200);
}

unsigned int readDistance()
{
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
unsigned long period = pulseIn(echoPin, HIGH);
return period * 343 / 2000;
}

#define NUM_ANGLES 7
unsigned char sensorAngle[NUM_ANGLES] = {60, 70, 80, 90, 100, 110, 120};
unsigned int distance[NUM_ANGLES];

void readNextDistance()
{
static unsigned char angleIndex = 0;
static signed char step = 1;
distance[angleIndex] = readDistance();
angleIndex += step;
if (angleIndex == NUM_ANGLES - 1)
step = -1;
else if (angleIndex == 0)
step = 1;

}

void setup()
{
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
digitalWrite(trigPin, LOW);

pinMode(enAPin, OUTPUT);
pinMode(in1Pin, OUTPUT);
pinMode(in2Pin, OUTPUT);
pinMode(in3Pin, OUTPUT);
pinMode(in4Pin, OUTPUT);
pinMode(enBPin, OUTPUT);

servo.attach(servoPin);
servo.write(90);

go(LEFT, 0);
go(RIGHT, 0);
testMotors();

servo.write(sensorAngle[0]);
delay(200);
for (unsigned char i = 0; i < NUM_ANGLES; i++)
readNextDistance(), delay(200);
}

void loop()
{
bool tooClose = false;
readNextDistance();
for (unsigned char i = 0; i < NUM_ANGLES; i++)
if (distance[i] < 300)
tooClose = true;

if (tooClose)
{
go(LEFT, -180);
go(RIGHT, -80);
}
else
{
go(LEFT, 255);
go(RIGHT, 255);
}
delay(50);
}

yusrashahbaz
Автор

can you put the codes of your obstacle avoidance robot please

secorinjohnvincent
Автор

😭😭😭Please I need the code very badly please give me the code

farahmaad
Автор

please send me the code, greetings from germany

bossfun
Автор

hey! i wanna ask you cause i connected my arduino uno and this code didn't work

imanebezzaz
Автор

bro can you share the code for controlling the motors

MuhammadSalman-mf
Автор

Hy can you send me the diagram and sketch please cause your link not working

sergerobichaud
Автор

Cool bro....that ultrasonic sensor holder idea is smart🔥🔥

JabiloJoseJ
Автор

oh my god no need coding? just install wire only??

kmhooibg
Автор

hello! first of all congradulations for this work, it's so good!!
please i want the code of obstacles avoiding car

ghislainekegnon
Автор

Mera arduino project pura nahin Ho Pa raha hai yaar
Thodi bahut programming mein dikkat a rahi hai

creative_lighting_ksg
Автор

Bonjour, combien de temp j'ai cherché cette vidéo et maintenant je la trouver
<<Qui cherche trouve>>

iyadhmeid
Автор

This is really helpful vedio & I wan to try. I could find only instructions pdf but not Arduino Sketch. Could you please help me with sketch link please ?.

kiranrudra