Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsRun two LEDs so that one is always on and the other always off, swapping over at a fixed rate. Two outputs now need managing at once, and the trick is that they are always opposites. Setting one HIGH in the same breath as setting the other LOW guarantees they can never both be lit. Try adding a second delay between the two digitalWrite() calls and you will see both LEDs briefly on together, a small experiment that shows exactly how literally the board follows the order you write.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin.
Every part for this build comes in the Geekobot Titan Kit box, a Geekobot exclusive, together with the parts for all 120 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.
ESP32 DevKit V1 (38-pin): the brain of every Titan Kit project, with Wi-Fi and Bluetooth
Male-to-female and female-to-female leads for the modules
LEDs from the kit's red, green, yellow and blue packs
220 ohm resistors: one in series with every LED
ESP32 expansion board from the kit: every GPIO has its own S, V, G header
Follow the colours: red is power, dark grey is ground, blue is a signal.
titan_kit_002_alternate_two_leds.inoVerify & upload in Electrolarkint redLed = 33;
int greenLed = 32;
int waitTime = 500;
void setup()
{
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
Serial.begin(9600);
}
void loop()
{
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
Serial.println("Red on, green off");
delay(waitTime);
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);
Serial.println("Green on, red off");
delay(waitTime);
}
Use a micro-USB data cable (some cables only charge), install the CP210x or CH340 driver if no port appears, pick Tools > Board > ESP32 Dev Module and hold the BOOT button on the board until the upload starts.
Turn it round: the long leg (anode) goes to the GPIO side through the 220 ohm resistor, the short leg to GND.
Set the Serial Monitor to 9600 baud, the same speed as Serial.begin() in the sketch, then press the EN button to restart the board.
Two outputs now need managing at once, and the trick is that they are always opposites. Setting one HIGH in the same breath as setting the other LOW guarantees they can never both be lit. Try adding a second delay between the two digitalWrite() calls and you will see both LEDs briefly on together, a small experiment that shows exactly how literally the board follows the order you write.
The red LED lights while the green one stays dark. After half a second they swap over. The alternation continues indefinitely.
Yes. It is project 2 of 120 in the Geekobot Titan Kit, in level 1 (Foundations). 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 Titan Kit project is wired on the ESP32 expansion board and the breadboard with jumper wires.
7 parts: ESP32-WROOM-32 38-Pin Development Board, USB Cable, Solderless Breadboard, Dupont Jumper Wires (40 pcs), 2 × Through-Hole LED Pack (Pack of 10), Carbon Film Resistor 1/4W 5% (Pack of 10) and ESP32 38-Pin 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 4 steps.
No. This page has the complete, tested code (titan_kit_002_alternate_two_leds.ino).
About ₹717 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Controlling several outputs; Keeping two states as exact opposites; Using a variable to hold a timing value; How instruction order affects what you see.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin.
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.