← All articles

29 October 2026

The Arduino Traffic Light: A First Project That Teaches Kids Timed Loops

Arduino traffic light

Has your child ever waited at a red light and asked: "How does it know when to change?" That is a wonderful question to start learning robotics with. The answer is not hidden inside some mysterious black box. It is a very simple program, repeating itself over time: red for a while, yellow for a while, green for a while, then back to the start. And your child can write that program themselves.

The traffic light is one of the best first projects for a child learning Arduino. It is familiar, visual, and the result is obvious at a glance: the lights change in the right order, at the right rhythm. Your child does not need to master theory before starting. They need three lights, a sense of timing, and an adult nearby asking the right questions.

What a traffic light teaches

First, it teaches the idea of a state. At any moment, a traffic light is in exactly one state: red, yellow, or green. It is never red and green at the same time. Building this project teaches your child to think in states: "What state are we in now, and what makes it move to the next one?" This is the foundational way of thinking behind every robot, from a vacuum robot to a self-driving car.

Second, it teaches a loop driven by time. A traffic light program does not run once and stop. It repeats forever: green, then yellow, then red, then green again. Your child meets the idea of "wait this many seconds, then do the next thing" — and learns that time itself is something a program can control, just like switching a light on or off.

Third, it teaches patience with order. Many children new to coding want everything to happen at once: turn all the lights on because it looks impressive. A traffic light forces them to go step by step. Red first, then yellow, then green. That discipline — doing things in the right order, without skipping steps — is something they will reuse in every project that follows.

A 30-minute first session

You do not need to buy anything. In a browser simulation, your child can wire up three LEDs — red, yellow, and green — each connected through a resistor. Do not launch into a long theory lesson about resistors. One simple sentence is enough: a resistor is like a tap opened just a little — it keeps the current from flowing so strongly that it damages the light.

Then your child writes the program to match the rhythm of a real street light: green on for a few seconds, off, yellow on for a shorter time, off, red on, then repeat. The first time, choose generous timings — say green for 5 seconds, yellow for 2, red for 5 — so young eyes can follow every change. Once the rhythm runs correctly, your child can shorten the timings to feel more like a real intersection.

This is where a parent matters most: do not fix the code for them. Instead, ask: "Which light is on right now? Which one should come next? How long do you want it to stay on?" These questions force your child to think about order and timing themselves, instead of copying a ready-made example.

Three common mistakes — and how to untangle them

The first mistake is lights on at the same time. The cause is almost always the same: your child switched a new light on but forgot to switch the old one off. This is a great mistake to learn from, because it teaches an important habit: before turning something new on, turn the old thing off. In code, that means every time the state changes, the other two lights must be switched off.

The second mistake is a rhythm that runs too fast to see. Your child has usually set the waiting time too short, or missed a wait command entirely. The fix is simple: make the times longer, run it again, and watch each change slowly. Learning robotics is not a speed race. Slow and correct always beats fast and wrong.

The third mistake is the order getting mixed up: yellow before green, or red after yellow. This one is easy to spot, because your child already knows the real order by heart from the street. Let them compare their program with a real traffic light: on the street, is it green, yellow, red — or red, yellow, green? When they find the swap themselves, they will remember it for a long time.

Upgrades once the basic rhythm works

When the three-color light runs correctly, do not stop there. There are plenty of upgrades still within reach of a beginner. Your child can add a button for pedestrians: when someone presses it, the light for cars turns red and the pedestrian light turns green. Or they can make the yellow light blink at night, just like many real intersections do when the road is quiet.

Another fun upgrade is changing the rhythm for "rush hour": green stays on longer in the morning when traffic is heavy, and shorter in the evening when the road is empty. Your child will start to grasp a bigger idea: a program does not have to repeat blindly — it can change its behavior based on conditions. That is the stepping stone toward sensors and robots that make their own decisions.

What a good session looks like

A good session is not the one where your child finishes fastest. It is the one where they can explain their own circuit: which light connects to which pin, why the resistor is there, and which step the program is on. Before closing the laptop, ask them to retell the rhythm in their own words: "First green for 5 seconds, then yellow for 2, then red for 5, then it repeats." If they can say that fluently, they have understood the lesson, even if the code is still a little rough.

And if the first session does not end with a finished project, that is completely fine. A traffic light is a small project, but it packs in three big ideas: states, time, and order. One session to get familiar, one to get it right, one to upgrade — that is a very healthy learning pace for a beginner.

Try it today, in the browser

Your child can start with the traffic light project and many more right in the browser with ManuStem: 28 lessons — 8 Component Lab lessons and 20 Competition Robot lessons — from the first LED to a self-avoiding robot. They wire circuits with AI Circuit support, get code suggestions from Gen AI, debug step by step with an Agent coach when stuck, and watch the robot run immediately in a 3D preview. For ages 8+, in Vietnamese and English, with 4 free trial lessons. (For ages 13+ who want to go further, there is a C++ track with ESP32 kits: mecanum wheels, ultrasonic and line sensors.)


ManuStem is a browser-based robotics platform for ages 8+ — no kit required, 28 lessons (8 Component Lab + 20 Competition Robot), with an AI co-pilot at every step. Start with 4 free trial lessons at stem.manusignal.com.

Read the Vietnamese version:

Đèn giao thông Arduino: dự án đầu tiên dạy con về vòng lặp theo thời gian