Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsTurn a single knob and sweep smoothly through the whole colour spectrum on an RGB LED. The potentiometer gives a number from 0 to 1023. That single number is stretched to a 0–764 colour wheel and then split into three stages: red fading into green, green into blue, and blue back into red. Each of the three channels is written with analogWrite(), which uses PWM, switching the LED on and off thousands of times a second so it appears dimmer or brighter rather than simply on or off.
Every part for this build comes in the Geekobot Explorer Kit box, a Geekobot exclusive, together with the parts for all 61 projects, from a first blinking LED to a smart fan and a reaction game. The wiring below is the kit's own wiring.
Tick anything you already have and the total updates.
The brain of every Explorer Kit project
Male-to-female and female-to-female leads for the modules
220 ohm resistors: one in series with every LED segment
10k potentiometer: a knob the Nano reads on an analog pin
Nano I/O shield from the kit: every pin has its own S, V, G header, so modules plug in with jumpers
Follow the colours: red is power, dark grey is ground, blue is a signal.
explorer_kit_18_rgb_mood_lamp.inoVerify & upload in Electrolarkint potPin = A0;
int redPin = 9;
int greenPin = 10;
int bluePin = 11;
void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop()
{
int potValue = analogRead(potPin);
int wheel = map(potValue, 0, 1023, 0, 764);
int r = 0;
int g = 0;
int b = 0;
if (wheel < 255)
{
r = 255 - wheel;
g = wheel;
b = 0;
}
else if (wheel < 510)
{
r = 0;
g = 510 - wheel;
b = wheel - 255;
}
else
{
r = wheel - 510;
g = 0;
b = 764 - wheel;
}
analogWrite(redPin, r);
analogWrite(greenPin, g);
analogWrite(bluePin, b);
delay(20);
}
Use the kit's mini-USB cable, install the CH340 driver on Windows if no port appears, pick Tools > Board > Arduino Nano and try Tools > Processor > ATmega328P (Old Bootloader) if the upload times out.
Check that it is the common-cathode type with the longest leg to GND, and that red, green and blue go to D9, D10 and D11 in that order.
The outer pins go to 5V and GND and the middle pin (wiper) to the analog pin.
The potentiometer gives a number from 0 to 1023. That single number is stretched to a 0–764 colour wheel and then split into three stages: red fading into green, green into blue, and blue back into red. Each of the three channels is written with analogWrite(), which uses PWM, switching the LED on and off thousands of times a second so it appears dimmer or brighter rather than simply on or off.
Knob fully left: pure red. Turning slowly: red → orange → green → cyan → blue → magenta. Knob fully right: back to red.
Yes. It is project 18 of 61 in the Geekobot Explorer Kit, in level 4 (Light, colour and sensing). Every part on the list comes in the kit box, and you can also buy the parts one by one from the list above.
No. Every Explorer Kit project is wired on the Nano I/O shield and the breadboard with jumper wires.
8 parts: Generic Nano CH340 Development Board (Soldered), USB Cable, Solderless Breadboard, Dupont Jumper Wires (40 pcs), 5mm RGB LED (Pack of 10), Carbon Film Resistor 1/4W 5% (Pack of 10), 16mm Rotary Potentiometer (Linear) and Arduino Nano IO Expansion Shield (328P Compatible). On this page you can tick the parts you already have and add only the rest to your cart.
It is a beginner project and takes about 30 minutes. The build on this page has 5 steps.
No. This page has the complete, tested code (explorer_kit_18_rgb_mood_lamp.ino).
About ₹482 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Analog input mapping to PWM output; The map() function; Mixing colours from three channels; Why analogWrite() only works on PWM (~) pins.
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Press to roll: the pips tumble and slow down before landing on a number.
Wait for the light, hit the button: how many milliseconds can you beat?
A bright 4-digit clock that keeps time through power cuts.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.