Robotic Car / Maze solving robot
Вставка
- Опубліковано 31 гру 2024
- Thank you all viewers and for your kind support.
Also refer my website link
digibigmarket....
How to use relay without Arduino
• How to use relay witho...
How to control RGB led color through IR remote and switch
• How to control RGB led...
IR Remote Tester using IR Receiver
www.youtube.co....
Disco LED Light
• Disco LED Light
Non-contact tester
• Non Contact Tester
LED voltage controller
• LED voltage controller.
Buzzer wire game
• Buzzer wire Game
Water level indicator
• Water Level Indicator
Electric car at home
• Electric Car at home
simple continuous tester at home
• Simple continuous test...
Vibrating Drawing bot
• Vibrating Drawing Bot
Music reactive LED
• Music reactive led
Simple music reactive LED
• Simple Music reactive LED
How to make a touch sensor
• How to make Touch sensor
Water Level Alarm
• Water Level Alarm
How to make autodetect night light sensor
• How to make night ligh...
good video.
Thanks for the visit
Plz refer below arduino code
#include
#include
#define MLa 8
#define MLb 9
#define MRa 10
#define MRb 11
#define trigpin 5
#define echopin 6
#define maximum_distance 200
boolean movestraight=false;
int distance=100;
NewPing sonar(trigpin,echopin,maximum_distance);
Servo servo_pin;
void setup()
{
pinMode(MLa,OUTPUT);
pinMode(MLb,OUTPUT);
pinMode(MRa,OUTPUT);
pinMode(MRb,OUTPUT);
servo_pin.attach(7);
servo_pin.write(115);
delay(2000);
distance=readping();
delay(100);
Serial.begin(9600);
}
void loop(){
int distanceright=0;
int distanceleft=0;
delay(100);
Serial.println(distance);
if(distance=distanceleft){
turnright();
delay(100);
movestop();
}
else{
turnleft();
delay(100);
movestop();
}
}
else{
moveforward();
}
distance=readping();
}
int lookright()
{
servo_pin.write(50);
delay(400);
int distance=readping();
delay(100);
servo_pin.write(115);
return distance;
}
int lookleft()
{
servo_pin.write(170);
delay(400);
int distance=readping();
delay(100);
servo_pin.write(115);
return distance;
}
int readping()
{
delay(50);
int cm=sonar.ping_cm();
if(cm==0){
cm=250;}
return cm;
}
void movestop()
{
digitalWrite(MRa,LOW);
digitalWrite(MRb,LOW);
digitalWrite(MLa,LOW);
digitalWrite(MLb,LOW);
}
void moveforward()
{
if(!movestraight){
movestraight=true;
digitalWrite(MRa,HIGH);
digitalWrite(MRb,LOW);
digitalWrite(MLa,HIGH);
digitalWrite(MLb,LOW);
}
}
void movebackward()
{
movestraight=false;
digitalWrite(MRa,LOW);
digitalWrite(MRb,HIGH);
digitalWrite(MLa,LOW);
digitalWrite(MLb,HIGH);
}
void turnright()
{
digitalWrite(MRa,LOW);
digitalWrite(MRb,HIGH);
digitalWrite(MLa,HIGH);
digitalWrite(MLb,LOW);
delay(500);
digitalWrite(MRa,HIGH);
digitalWrite(MRb,LOW);
digitalWrite(MLa,HIGH);
digitalWrite(MLb,LOW);
}
void turnleft()
{
digitalWrite(MRa,HIGH);
digitalWrite(MRb,LOW);
digitalWrite(MLa,LOW);
digitalWrite(MLb,HIGH);
delay(500);
digitalWrite(MRa,HIGH);
digitalWrite(MRb,LOW);
digitalWrite(MLa,HIGH);
digitalWrite(MLb,LOW);
}
Code?
how i can but speed in code with servo