Smart Room Light System

by SS09finals in Circuits > Arduino

49 Views, 0 Favorites, 0 Comments

Smart Room Light System

unnamed.jpg

This project involves creating an RGB motion-activated system based on an Arduino Uno, PIR motion, and ultrasonic distance sensors. If the detection is within range, the detected distance causes color changes of the RGB LED. Such projects can serve multiple purposes related to automated lighting and security applications, and can be made fun through an interactive display.

Supplies

OIP.jpg
R.jpg
RGB-LEDs-Pinout.png
OIP.jpg
pir-sensor-3-1024x1024.jpg
515c7a2bce395f653d000002.png
  1. You will need :
  2. Arduino Uno
  3. RGB LED (Common Anode)
  4. PIR Motion Sensor
  5. Ultrasonic Distance Sensor (HC-SR04)
  6. 3x 330Ω Resistors
  7. Breadboard
  8. Jumper Wires
  9. USB Cable for Arduino

Circuit Assembly - RGB LED

To connect the RGB LED (Common Anode). You will need to connect the common anode/longest pin to the positive rail of the breadboard. Red Pin goes to D3 via a 330Ohm Resistor. Green Pin to D5 via a 330Ohm Resistor and Blue Pin to D6 via a 330Ohm Resistor

PIR Motion Sensor

First connect VCC to positive rail on Breadboard. Then, connect GND to GND rail on Breadboard. Finally the "OUT" or "SIGNAL" to D2 on the Arduino.

Ultrasonic Distance Sensor

First connect VCC to power on Breadboard, then connect GND to Ground on Breadboard. Now connect trig to D9 and echo to D10 on Arduino.

Writing the Code

arduino-ide.png
What-is-arduino-software-IDE-and-how-use-it.jpg
  1. The Arduino controls the PIR Motion Sensor, if someone moves it tells the Arduino, just like the Distance Sensor.
  2. Depending on how far the object is:
  3. If it's very close (less than 20 cm), the LED turns red.
  4. If it's a little far (20-50 cm), the LED turns green.
  5. If it's far away (more than 50 cm), the LED turns blue.
  6. If there is no movement, the LED stays white.

Writing Code :

  1. #define Statements: these name the pins on the Arduino so it is easier to know what each pin does
  2. void setup() function : This is where we tell the Arduino which pins are inputs and outputs and we can also tell the Arduino to talk to us using "Serial.begin(9600);"
  3. void loop() function : This is lines of code that run over and over again in a loop, it checks if motion is detected and if yes it calls measureDistance() to find how far the object is and changes the LED Color
  4. setColor() function: Changes the RGB LED color by adjusting how much red green and blue light is used.

Testing and Troubleshooting

  1. Upload the code to the Arduino Board
  2. Check and see if motion and distance sensors work by checking the serial monitor
  3. Check the colors based on how close or far you are
  4. If the LED doesn't work, check the wires!
  5. Don't forget to tune your PIR Motion Sensor


Final Step : Nothing! Your Done!