Introduction of the Project
Are you tired of plain and boring night lamps? Do you want to add a pop of color to your bedroom? Look no further than an automated colorful night lamp with Arduino! Using the power of Arduino programming, this lamp can cycle through a variety of colors and patterns, creating a dynamic and eye-catching display. And the best part? You don’t need any specialized technical skills to build it.
With a few basic electronic components and a little bit of coding know-how, you can create a custom, one-of-a-kind lamp that will brighten up your nights and impress your friends. So why settle for a boring old lamp when you can have a colorful and automated one? Let’s get started!
Supplies
To build this Arduino project, we will use RGB LED and some sensors. If you are doing a physical project, the components can be purchased online or from any electronics center.
We have used the TinkerCad website and the following components:
Components
- Arduino Uno R3
- PhotoResistor Sensor
- Ultrasonic Distance Sensor
- 1 RGB LED
- 4 Resistors
- 1 Small Breadboard
- Connecting Wires
Circuit Diagram
Steps To Build An Automated Colorful Night Lamp With Arduino
Step 1: Gather all the above-mentioned components on the Digital Board or Physical Table.
RGB LED:
Step 2: Connect the Cathode terminals of RGB LED to the GND pin of the Arduino.
Step 3: Connect the Red, Blue, and Green terminals of RGB LED to the different number pins of the Arduino from 11 to 13 through resistors.
Ultrasonic Distance Sensor:
Step 4: Connect the Ground terminal of the Ultrasonic Distance Sensor to the GND pin of the Arduino.
Step 5: Connect the Power terminal of the Ultrasonic Distance Sensor to the 5V pin of the Arduino.
Step 6: Connect the Signal terminal of the Ultrasonic Distance Sensor to the A1 pin of the Arduino.
PhotoResistor Sensor:
Step 7: Connect the first terminal of the PhotoResistor Sensor to the GND pin of the Arduino through a resistor and the same with the A0 pin of the Arduino.
Step 8: Connect the second terminal of the PhotoResistor Sensor to the 5V pin of the Arduino.
Source Code
void setup() { pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); pinMode(A1, INPUT); pinMode(A0, INPUT); } void loop() { int status = analogRead(A0); int presence = analogRead(A1); if(status < 500 && presence < 100) { digitalWrite(11, 0); digitalWrite(12, 0); digitalWrite(13, 255); delay(1000); digitalWrite(11, 255); digitalWrite(12, 0); digitalWrite(13, 0); delay(1000); digitalWrite(11, 255); digitalWrite(12, 255); digitalWrite(13, 0); delay(1000); digitalWrite(11, 255); digitalWrite(12, 0); digitalWrite(13, 255); delay(1000); } else { digitalWrite(11, 0); digitalWrite(12, 0); digitalWrite(13, 0); } }
Explanation of the Code
1. In the setup function, we have configured the pins of the Arduino for input & output purposes to glow the LED and take input from the sensors.
2. In the loop function, we are reading the value of the two sensors, storing it in a variable, and then using the if-else statement to glow the LED accordingly if the condition is satisfied.
3. The delay function takes the value of time in milliseconds.
Output
We will get the following output on building this automated colorful night lamp with Arduino.
On starting the simulation, the RGB LED will glow if there is no light in the room and there’s someone inside the room.

Cisco Ramon is an American software engineer who has experience in several popular and commercially successful programming languages and development tools. He has been writing content since last 5 years. He is a Senior Manager at Rude Labs Pvt. Ltd.
0 Comments