Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

How To Make a RGB LED Mood

Light with Arduino – Detailed Guide

Step by Step Instructions to Create a Customizable LED Light with


Smooth Transition Colors to Suit Any Occasion or Preference

Getting Started
Materials Needed:
● Arduino Board (Arduino Uno or Nano)
● Common cathode RGB LED (or three separate LEDs for red, green, and
blue)
● 3 x 220-330 ohm resistors
● Breadboard or Custom PCB
● Jumper Wires
● 5V Power Supply
● Smartphone or Computer for Control

Process

STEP 1: UNDERSTANDING THE RGB LED


- The three internal LEDs in an RGB LED package are red, green, and blue.
To produce a variety of colors, one can control each color separately.
Knowing the data protocols and wiring for the particular type of RGB LED
you have is crucial.

STEP 2: INSTALL ARDUINO IDE


- If you haven't already, download and install the Arduino IDE from the
official Arduino website (https://www.arduino.cc/en/software).

STEP 3: WIRING THE RGB LED


- Connect the RGB LED as follows:
- Hook the RGB LED's longest leg, or anode, to the Arduino's 5V output.
- Attach the red, green, and blue LEDs' three shorter legs, or cathodes, to
the Arduino's digital pins (Pins 9, 10, and 11).
- Put a 220-330 ohm resistor in series with each cathode connection. In
order to shield the LEDs from excessive current, this resistor limits the
amount of current that gets to them.

STEP 4: WRITING THE ARDUINO CODE


- The LED mood light can be controlled by creating an Arduino sketch. The
brightness of each color channel (red, green, and blue) will be adjusted
using the analogWrite function.
- In your code, specify which pins go with which color channel.
- Set the pins as outputs in the setup() function.
- In the loop() function, use analogWrite to control the intensity of each
color by providing values from 0 (off) to 255 (maximum intensity)

EXAMPLE CODE:
const int redPin = 9;
const int greenPin = 10;
const int bluePin = 11;
int delayTime = 10;

void setup() {
pinMode (redPin, OUTPUT);
pinMode (greenPin, OUTPUT);
pinMode (bluePin, OUTPUT);
}

void loop() {
for (int i = 0; i < 256; i++) {
analogWrite (redPin, i);
delay (delayTime);
}

for (int i = 255; i >= 0, i-- ) {


analogWrite (greenPin, i);
delay (delayTime);
}
for (int i = 0; i < 256; i++) {
analogWrite (bluePin, i);
delay (delayTime);
}
}

STEP 5: UPLOAD THE CODE


- Connect your arduino to your computer via USB.
- Open the arduino IDE, select your board, and port, and then upload the
code to the arduino.

STEP 6: TEST AND CONTROL THE MOOD LIGHT


- After uploading the code, your RGB LED mood light will start to show the
different colors and animations that you have set up. Changing the code
allows you to play around with various patterns and effects.

STEP 7: SMARTPHONE CONTROL (OPTIONAL)


- To enhance convenience, you can integrate smartphone control with
Bluetooth or Wi-Fi modules such as ESP8266/ESP32 or HC-05/HC-06. This
enables you to use a remote control or a mobile app to control the mood
light.

STEP 8: MOUNT AND ENJOY


- A mounting surface or enclosure should be used to secure the RGB LED.
Set the desired colors and lighting effects with your control method after
placing your DIY mood light in your room to create the ideal atmosphere
for any occasion. You can now play around with different colors,
animations, and patterns to fit any mood or style preference.

You might also like