IR Sensor Digital Output on Arduino

IR sensors can be used for obstacle avoidance on Arduino vehicles. Using the digital output option you can code based on a simple true false statement rather than testing against a range.

Functional Parts in the Project:

#define IR 8

int Obstacle;

void setup() {
  pinMode(IR, INPUT);

void loop() {
  Obstacle = digitalRead(IR);

  if (Obstacle == LOW) {
 else {
   Serial.println("All Clear");


Be the first to comment

Leave a Reply