Arduino Uno Based PIR Sensor.
Arduino Uno Based PIR Sensor.
• Connect the PIR sensor to the Arduino Uno. The VCC pin of the sensor goes to the 5V
pin on the Arduino, GND to GND, and the OUT pin to a digital input pin (e.g., D2) on
the Arduino.
• Connect an LED to another digital pin (e.g., D13) with a 220Ω resistor in series.
• Use jumper wires to make all necessary connections on the breadboard.
• Open the Arduino IDE and write the code to read the digital output from the PIR sensor
and control the LED based on motion detection.
• Upload the code to the Arduino Uno.
• Power the Arduino Uno using a USB cable or an external power supply.
• Observe the LED and the serial monitor in the Arduino IDE to see the motion detection
readings and the LED status.
IRE 216: Sensor Technology Sessional
Sketch:
void loop() {
// Read the PIR sensor's output
int pirState = digitalRead(pirPin);
// Check if motion is detected
if (pirState == HIGH) {
// Motion detected, turn on the LED and buzzer
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(buzzerPin, HIGH);
Serial.println("Motion detected!");
} else {
// No motion, turn off the LED and buzzer
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
Serial.println("No motion.");
}
// Small delay for stability
delay(1000);
}
Conclusion:
This experiment successfully demonstrates the use of an Arduino Uno and a PIR sensor to detect motion
and control an LED. The PIR sensor outputs a digital signal when motion is detected, which is read by the
Arduino to turn on the LED. This setup can be used in various applications, such as security systems and
automated lighting.