ARDUINO WITH IR SENSOR

In this tutorial you will get to know that how you can create an Infrared detection system .




Material requirements are given below :-
  • IR SENSOR
  • ARDUINO
  • GREEN LED
  • RED LED
  • BRAEDBOARD
  • JUMPER WIRES


Whenever any object comes in front of IR sensor red starts glowing otherwise green led glows indicating no object in front.
The range of sensor can be changed by changing the direction of regulator present on sensor.

CONNECTIONS
ARDUINO
GND          =     -ve of green , red LED and
                          GND of IRsensor
5V              =     VCC of IR sensor
2                =      +ve of red LED
3                =      +ve of green LED 
4                =      OUT of IR sensor


CODE OF THE PROJECT :-

const int IR = 4;
const int green = 3;
const int red = 2;

void setup() {
pinMode(IR, INPUT);
pinMode(green, OUTPUT);
pinMode(red, OUTPUT);
}


void loop() {
if(digitalRead(IR) == HIGH){
  digitalWrite(green,LOW);
  digitalWrite(red,HIGH);
}


else{
  digitalWrite(green,HIGH);
  digitalWrite(red,LOW);
 
}
}

Popular posts from this blog

ARDUINO WITH PCA9685

TELEGRAM WITH RASPBERRY PI