Arduino IR Obstacle Avoidance Vehicle

This project will allow you to create a basic autonomous obstacle avoidance vehicle with Arduino.

Functional Parts in the Project:

#include <Servo.h>

#define IR 7

Servo lServo;
Servo rServo;

int Obstacle;


void setup() {
  pinMode(IR, INPUT);
  lServo.attach(8);
  rServo.attach(9);
}

void loop() {
  Obstacle = digitalRead(IR);
  if (Obstacle == LOW)
  {
    lServo.write(80);
    rServo.write(100);
  }
  else
  {
    lServo.write(80);
    rServo.write(80);

  }
  delay(100);
}

Be the first to comment

Leave a Reply