Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anujesh-ansh/motion-sensor-lamp
https://github.com/anujesh-ansh/motion-sensor-lamp
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/anujesh-ansh/motion-sensor-lamp
- Owner: Anujesh-Ansh
- Created: 2024-04-24T09:03:37.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-04-24T09:34:55.000Z (7 months ago)
- Last Synced: 2024-04-25T14:45:42.147Z (7 months ago)
- Language: C++
- Size: 396 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Motion Sensor Lamp Project
Welcome to the Motion Sensor Lamp project! ๐
Experience the magic of creating your own motion-activated lamp using a PIR sensor, LED, resistor, Arduino, and a breadboard. Let's dive into the details of how to set it up and bring this project to life! ๐
## Components Needed
- PIR (Passive Infrared) Sensor
- LED ๐ก
- 220 ohm Resistor
- Arduino Board ๐ ๏ธ
- Breadboard ๐
- Connecting wires ๐งต## Circuit Connection
Follow these steps to connect the components:
1. Connect the **5V** from the Arduino to the **positive line** of the breadboard (`๐ฅ red wire`).
2. Connect the **GND** from the Arduino to the **negative line** of the breadboard (`โฌ๏ธ black wire`).
3. Connect the **GND** (Ground) pin of the PIR sensor to the **negative line** of the breadboard (`โฌ๏ธ black wire`).
4. Connect the **Power** pin of the PIR sensor to the **positive line** of the breadboard (`๐ฅ red wire`).
5. Connect the **Signal** pin of the PIR sensor to **Digital Pin 2** of the Arduino (`๐จ yellow wire`).
6. Connect **Digital Pin 13** of the Arduino to the **anode (+)** of the LED (`๐ฉ green wire`).
7. Connect one end of the **220 ohm resistor** to the **cathode (-)** of the LED.
8. Connect the other end of the **220 ohm resistor** to the **negative line** of the breadboard (GND) (`โฌ๏ธ black wire`).![Circuit Diagram](https://github.com/Anujesh-Ansh/Light-using-Motion-Detection/raw/main/circuit-image.JPG)
Now that your circuit is set up, let's move on to the code implementation!
## Arduino Code
```cpp
int pirsensor = 0;void setup()
{
pinMode(13, OUTPUT); // Set digital pin 13 as an OUTPUT
pinMode(2, INPUT); // Set digital pin 2 as an INPUT for PIR sensor
}void loop()
{
pirsensor = digitalRead(2); // Read the value from PIR sensor connected to pin 2if (pirsensor == HIGH)
{
digitalWrite(13, HIGH); // Turn on the LED if motion is detected
}
else
{
digitalWrite(13, LOW); // Turn off the LED if no motion is detected
}delay(10); // Delay for stability
}
```## Usage
1. Upload the provided Arduino code to your Arduino board.
2. Power the circuit by connecting the Arduino to a USB port or an external power source.
3. Place the PIR sensor in a location where it can detect motion.
4. When motion is detected, the LED will illuminate, creating your motion-activated lamp! ๐กEnjoy experimenting with this fun and practical project. Happy making! ๐ ๏ธ