Obstacle avoiding robot using IR proximity sensor
HTML-код
- Опубликовано: 3 ноя 2017
- SKETCH OF THIS PROJECT
int motor1a=6;
int motor1b=9;
int motor2a=10;
int motor2b=11;
int sensorr=2;
int sensorl=4;
int sensorrstate =0;
int sensorlstate=0;
void setup()
{
pinMode(motor1a,OUTPUT);
pinMode(motor1b,OUTPUT);
pinMode(motor2a,OUTPUT);
pinMode(motor2b,OUTPUT);
pinMode(sensorr,INPUT);
pinMode(sensorl,INPUT);
}
void loop() {
sensorrstate=digitalRead(sensorr);
sensorlstate=digitalRead(sensorl);
if(sensorrstate==LOW){
digitalWrite (motor1a,LOW);
digitalWrite (motor1b,HIGH);
digitalWrite (motor2a,HIGH);
digitalWrite (motor2b,LOW);
delay(500);
}
if(sensorlstate==LOW){
digitalWrite (motor1a,HIGH);
digitalWrite (motor1b,LOW);
digitalWrite (motor2a,LOW);
digitalWrite (motor2b,HIGH);
delay(500);
}
if((sensorlstate==LOW)&&(sensorrstate==LOW))
{
digitalWrite (motor1a,HIGH);
digitalWrite (motor1b,LOW);
digitalWrite (motor2a,HIGH);
digitalWrite (motor2b,LOW);
delay(500);
}
if((sensorrstate==HIGH)&&(sensorlstate==HIGH))
{
digitalWrite (motor1a,LOW);
digitalWrite (motor1b,LOW);
digitalWrite (motor2a,LOW);
digitalWrite (motor2b,LOW);
delay(500);
}
}
Thanks for making this video;) really helpful.
Thank you so much
I would like to ask if what is the green one? is that a motor shield or a L298N H-bridge motor driver? thanks
Andrea Louis Basbas yeah it's not a L298N but it's a L293D motor driver but ppl call it motor shield too ... U r welcome ☺️
Can u give me schematic diagram?
nice one
sanjay sanju thanks macha
Hi, Let me clarify the specific name of your sensor? Is it IR Proximity Sensor?
nice!
there are two spelling mistakes in the code :digutal and dealy
Nice😁
Pls provide me the diagram