Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsAn Arduino pin is either on or off, but switching it very fast and changing how long it stays on each time (PWM) makes an LED look dimmer or brighter. analogWrite() does that on the PWM pins (3, 5, 6, 9, 10, 11) with a value from 0 to 255. The potentiometer on A0 sets the value, so the knob becomes a dimmer.
Every part for this build comes in the Geekobot Spark Kit box, a Geekobot exclusive, together with the parts for all 24 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 Spark Kit project
220 ohm resistor pack: limits the LED current
Sensor Shield v5.0 from the kit: every pin has its own G, V, S header, so modules plug in with female jumpers
Follow the colours: red is power, dark grey is ground, blue is a signal.
spark_kit_21_led_brightness_control.inoVerify & upload in Electrolark// Spark Kit 21: LED brightness control
int pot = A0;
int led = 9; // PWM pin
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
int value = analogRead(pot); // 0..1023
int brightness = map(value, 0, 1023, 0, 255); // 0..255
analogWrite(led, brightness);
delay(10);
}
Use the kit's USB cable (some phone cables carry power only), install the CH340 driver on Windows if the port does not appear, and pick Tools > Board > Arduino Uno.
It is on a pin without PWM. Use D9, or another pin marked with a ~.
Normal: our eyes see brightness on a curve. Try brightness = brightness * brightness / 255.
Pulse-width modulation: the pin switches on and off about 490 times a second, and the share of on-time sets the average power.
Yes, through the L298N ENA pin, as suggested in project 20.
Yes. It is one of the 24 projects in the Geekobot Spark Kit, and every part on the list comes in the kit box. You can also buy the parts one by one from the list above.
No. Every Spark Kit project is wired on the breadboard or the Sensor Shield with jumper wires.
8 parts: Uno R3 CH340G ATmega328p Compatible Development Board, Arduino USB-A to USB-B Data Cable for UNO/MEGA, 16mm Rotary Potentiometer (Linear), Through-Hole LED Pack (Pack of 10), Carbon Film Resistor 1/4W 5% (Pack of 10), Solderless Breadboard, Dupont Jumper Wires (40 pcs) and Arduino Sensor Shield V5 Expansion Board. 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 20 minutes. The build on this page has 5 steps.
No. This page has the complete, tested code (spark_kit_21_led_brightness_control.ino).
About ₹441 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
PWM with analogWrite(); Mapping 0-1023 to 0-255; Smooth output control.
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.