IR Infrared Obstacle Avoidance Sensor Module

IR Infrared Obstacle Avoidance Sensor Module for Arduino
Price: $3.50

This will detect an object from 2cm to 30cm with a detection angle of 35 degrees. There is a  range adjustment control.

Uses 3-5V DC.

 

EXAMPLE CODE: // IR Obstacle Collision Detection Module // Henry's Bench

int LED = 13; // Use the onboard Uno LED

int isObstaclePin = 7; // This is our input pin

int isObstacle = HIGH; // HIGH MEANS NO OBSTACLE

void setup() {

pinMode(LED, OUTPUT);

pinMode(isObstaclePin, INPUT);

Serial.begin(9600);

}

void loop() {

isObstacle = digitalRead(isObstaclePin);

if (isObstacle == LOW) {

Serial.println("OBSTACLE!!, OBSTACLE!!");

digitalWrite(LED, HIGH);

}

else {

Serial.println("clear");

digitalWrite(LED, LOW);

}

delay(200);

}