Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Hackster is hosting Impact Spotlights: Industrial Automation. Watch the stream live on Thursday!Hackster is hosting Impact Spotlights: Industrial Automation. Stream on Thursday!
Raushan Kumar
Published © Apache-2.0

Arduino with IR Sensor

How to interface an IR sensor with an Arduino Uno.

BeginnerFull instructions provided1 hour330,745
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

Raushan Kumar
32 projects • 72 followers
Contact

Comments

Please log in or sign up to comment.