jehankandt
Published © Apache-2.0

Arduino with IR Sensor

IR Sensor project with Arduino

IntermediateFull instructions provided16
Arduino with IR Sensor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Resistor 220 ohm
Resistor 220 ohm
×2
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Green
5 mm LED: Green
×1
IR Range Sensor
Digilent IR Range Sensor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Arduino with IR Sensor

C/C++
Arduino with IR Sensor
//...............JehanKandy........................
//........www.jehankandy.com.......................
//........www.github.com/JehanKandy................

//....................IR Sensor....................
//.....................if else.....................


//create Variables.....
int sPin = 3; //sensor OUT pin
int G_LED = 4; //Green LED pin
int R_LED = 5; //Red LED pin
int t = 1000; //delay Time

void setup() {
  //Identify input and outputs..
  pinMode(sPin,INPUT); //sensor pin INPUT 
  pinMode(G_LED,OUTPUT); //Green LED
  pinMode(R_LED,OUTPUT); //Red LED
}

void loop() {
  if(digitalRead(sPin)==HIGH){ //check for the sensor value
    digitalWrite(G_LED,HIGH); //Green LED on
    digitalWrite(R_LED,LOW); //Red LED off
  }
  else{
    digitalWrite(G_LED,LOW); //Green LED on
    digitalWrite(R_LED,HIGH); //Red LED off
  }
}

// ................Thank You......................

Credits

jehankandt

jehankandt

0 projects • 1 follower

Comments

Add projectSign up / Login