Alfa
Published © Apache-2.0

Arduino with IR Sensor

How to interface an IR sensor with an Arduino Uno.

BeginnerFull instructions provided1 hour330,177
Arduino with IR Sensor

Things used in this project

Story

Read more

Code

Code

Arduino
int IRSensor = 2; // connect ir sensor to arduino pin 2
int LED = 13; // conect Led to arduino pin 13



void setup() 
{



  pinMode (IRSensor, INPUT); // sensor pin INPUT
  pinMode (LED, OUTPUT); // Led pin OUTPUT
}

void loop()
{
  int statusSensor = digitalRead (IRSensor);
  
  if (statusSensor == 1)
    digitalWrite(LED, LOW); // LED LOW
  }
  
  else
  {
    digitalWrite(LED, HIGH); // LED High
  }
  
}

Credits

Alfa

Alfa

32 projects • 69 followers

Comments