Overview
This project tells about how to use a PIR sensor to glow an LED this is very useful to detect the presence of living beings.
In this project when there is any living being present near the range of the PIR sensor the LED will glow in the rest of the cases Led will be Off.
Hardware required
- Arduino Uno R3
- LED
- Resistor
- Jumper Wires
- PIR Sensor
Schematic Diagram
Fig 1. Circuit Diagram
Arduino Code :
int led = 2;
int sensor = 13;
void setup() {
pinMode(led, OUTPUT);
pinMode(sensor, INPUT);
Serial.begin(9600);
}
void loop() {
int sensorval = digitalRead(sensor);
Serial.println(sensorval);
if (sensorval == HIGH) {
digitalWrite(led, HIGH);
}
else {
digitalWrite(led, LOW);
}
}
Precautions
- Connections should be done properly.
- Arduino is case Sensitive so code accordingly.
- Give different and appropriate colors to the wires.
- Use resistors for sensors and LED’s.