In this article we’ll see how to design an Arduino PWM RGB Mood Light and Simulate it on Tinkercad.
The circuit connection is so simple and this is the best thing about RGB Mood Light Circuits, its simplicity.
You can assemble it from Arduino Board and Three LEDs. One Red LED, one Green LED and one Blue LED.
Here is the circuit.
The code is very simple. You can get it from examples from Arduino IDE. Here is the Fading exmple from Arduino IDE that uses the Analog Output.
Here is a modified version of the code in which we made it control three LEDs instead of only one LED.
int LEDRED = 11; // LED connected to digital pin 11
int LEDGREEN = 10; // LED connected to digital pin 10
int LEDBLUE = 9; // LED connected to digital pin 9
void setup() {
// nothing happens in setup
}
void loop() {
// fade in from min to max in increments of 5 points:
for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
// sets the value (range from 0 to 255):
analogWrite(LEDRED, fadeValue);
analogWrite(LEDGREEN, fadeValue+10);
analogWrite(LEDBLUE, fadeValue+30);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// fade out from max to min in increments of 5 points:
for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
// sets the value (range from 0 to 255):
analogWrite(LEDRED, fadeValue);
analogWrite(LEDGREEN, fadeValue+10);
analogWrite(LEDBLUE, fadeValue+30);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}
Here is the simulation on Tinkercad that you can see how control fading LED using PWM signals generated from Arduino.
Notes:
You can safely connect LEDs to Arduino Board without any problem. The currecnt from Arduino is safe for the LEDs. You don’t need to connect resistors between LEDs and Arduino.
Another note is that you can use this same PWM signals to control the motors using Arduino and Motor Shield.
The PWM signals control the speed of the motors.
We’ll see how to do this in another example.
Thank you.