This project implements a motion-activated light bulb using an Arduino Uno, PIR motion sensor, and a light bulb. The sensor detects motion in the environment and turns on the light bulb. The light bulb remains on for a set period of time and then turns off automatically.
- Arduino Uno
- PIR Motion Sensor
- Breadboard
- Light Bulb
- 2N3904 NPN Transistor
- 1k Ohm Resistor
- Jumper Wires
Recording.2023-03-17.112128.mp4
Recording.2023-03-17.112000.mp4
Connect breadboard with 5V and GND pins from Arduino Uno board. You can place sensor anywhere you want and light bulb too. Sensor has to be connected with power and ground also has to have signal pin connected to any digital pin but in this project we are using ping 2 for it. Light bulb is connected to ground and digital pin 3.
- Install the Arduino IDE on your computer if you haven't already done so.
- Open the Arduino IDE and create a new project.
- Copy and paste the code from the firstType.cpp or secondType.cpp file in this repository into the project.
- Upload the project to the Arduino Uno board.
- Power on the Arduino Uno board.
- The light bulb will remain off until motion is detected by the PIR motion sensor.
- When motion is detected, the light bulb will turn on and remain on for a set period of time (20 seconds by default).
- After the set period of time has elapsed, the light bulb will turn off automatically.
- If the light bulb does not turn on when motion is detected, check your wiring connections and make sure the PIR motion sensor is properly positioned.
- If the light bulb remains on indefinitely, check the delay time in the code and make sure it is set to the desired value.
This project was inspired by the PIR Motion Sensor example project in the Arduino IDE and modified to include a light bulb and transistor for controlling the light. The code was written by charon.