4pin IR Infrared Obstacle Avoidance Sensor Module KY032

4pin IR Infrared Obstacle Avoidance Sensor Module KY032

Description :

Basically its an IR emitter and receiver, the receiver detects when an obstacle has been placed in the beam of the IR emitter output this is then sent back as a logic low when an obstacle is present and a logic high when no obstacle is present, when connected to and Arduino you can perform an action, a common use would be in a robot where you wished to detect the presence of an object, lets say a wall and either stop or change direction, your robot may in fact have more than one of these.

Source code :

int detector = 8; // define the obstacle avoidance sensor interface
int val ;
 
void setup ()
{
  pinMode(13, OUTPUT);     // Built in Arduino LED
  digitalWrite (13, LOW);
  pinMode (detector, INPUT) ;// define the obstacle avoidance sensor output interface
}
 
void loop ()
{
  val = digitalRead (detector) ;
  if (val == HIGH) // When the obstacle avoidance sensor detects a signal, LED flashes
  {
    digitalWrite (13, HIGH);
    delay(100);
  }
  else
  {
    digitalWrite (13, LOW);
    delay(100);
  }
}

 


 

Write a review

Please login or register to review
  • Views: 4179
  • Brand: Tiah
  • Product Code: DZD001913
  • Availability: 13
  • 350.00DA
  • Ex Tax: 350.00DA

Tags: 4pin, ir, infrared, obstacle, avoidance, sensor, module, ky032