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);
    }
    }

Комментарии • 12

  • @CAPSTV
    @CAPSTV 4 года назад +1

    Thanks for making this video;) really helpful.

  • @lucnguyentan5822
    @lucnguyentan5822 4 года назад

    Thank you so much

  • @andrealouisbasbas6325
    @andrealouisbasbas6325 6 лет назад +1

    I would like to ask if what is the green one? is that a motor shield or a L298N H-bridge motor driver? thanks

    • @srinivasreddy6594
      @srinivasreddy6594  6 лет назад

      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 ☺️

  • @rajaiejulaihi4249
    @rajaiejulaihi4249 4 года назад

    Can u give me schematic diagram?

  • @sanjaynataraj6730
    @sanjaynataraj6730 6 лет назад +1

    nice one

  • @charlemagnealexander
    @charlemagnealexander 5 лет назад

    Hi, Let me clarify the specific name of your sensor? Is it IR Proximity Sensor?

  • @sahilthapa2291
    @sahilthapa2291 5 лет назад

    nice!

  • @brosiman
    @brosiman 4 года назад

    there are two spelling mistakes in the code :digutal and dealy

  • @fakiyashaikh113
    @fakiyashaikh113 6 лет назад

    Nice😁

  • @engexperts8687
    @engexperts8687 5 лет назад

    Pls provide me the diagram