Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsA traffic signal is a fixed sequence of outputs with set times: red for 3 seconds, yellow for 1, green for 3, and round again. Three LEDs on pins D12, D11 and D10, each with its own 220 ohm resistor, model it exactly, and the sketch shows how to switch several outputs together in each step.
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
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_03_traffic_light.inoVerify & upload in Electrolark// Spark Kit 03: traffic light
int red = 12;
int yellow = 11;
int green = 10;
void setup() {
pinMode(red, OUTPUT);
pinMode(yellow, OUTPUT);
pinMode(green, OUTPUT);
}
void light(int r, int y, int g, int ms) {
digitalWrite(red, r);
digitalWrite(yellow, y);
digitalWrite(green, g);
delay(ms);
}
void loop() {
light(HIGH, LOW, LOW, 3000); // red 3 s
light(LOW, HIGH, LOW, 1000); // yellow 1 s
light(LOW, LOW, HIGH, 3000); // green 3 s
}
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.
That LED is backwards or its resistor is in the wrong row. Swap it with a working one to test.
Two signal wires share a breadboard row. Each resistor needs its own row.
Yes: wire a push button as in project 04 and start the red phase early when it is pressed.
It keeps loop() short and shows each phase on one line, so changing a time is easy.
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.
7 parts: Uno R3 CH340G ATmega328p Compatible Development Board, Arduino USB-A to USB-B Data Cable for UNO/MEGA, 3 × 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 30 minutes. The build on this page has 6 steps.
No. This page has the complete, tested code (spark_kit_03_traffic_light.ino).
About ₹457 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Controlling several outputs; Building a timed sequence; Modelling a real system in code.
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.