ECEdge

Exam: GATE 2027 exams are on 6, 7, 13, 14, 20 and 21 February 2027. Official GATE 2027 site

Traffic light controller as a state machine

  • PathFoundation
  • LevelBeginner
  • Time1 weekend
  • Partsabout ₹1,000

Build a traffic light with a pedestrian button on an Arduino, written as a proper finite state machine with non-blocking timing, the way real controllers are written.

What this proves to recruiters

  • You can design a finite state machine before coding it.
  • You can write non-blocking code with millis() instead of delay().
  • You can handle inputs like a button without missing them.

Skills you will use

States and what moves between them30 s or button3 s1 s10 sGREENYELLOWREDWALKstart
Four states. The button only shortens GREEN, so cars always get a fair turn.

Parts list

You can buy the listed parts online here:

PartQtyApprox. priceShop
Arduino Uno compatible board with USB cable1₹550Find on Amazon
Breadboard, 830 points1₹90Find on Amazon
Jumper wire set (male-male and male-female)1₹120Find on Amazon
LED pack, assorted colours1₹60Find on Amazon
Resistor kit, ¼ W, assorted values1₹150Find on Amazon
Push buttons, pack of 101₹40Find on Amazon
Total, about₹1,000

Prices are rough online prices in India and change with the seller. You may already have some parts, or find them in your college lab.

As an Amazon Associate I earn from qualifying purchases. Buying through these links costs you nothing extra and helps keep this site free.

Free software

  • Arduino IDE
  • Wokwi simulator (no hardware needed to start)

Steps

  1. Draw the state diagram: GREEN, YELLOW, RED and WALK, with the time or event that moves between them.
  2. Write an enum for the states and one switch statement that decides what each state does.
  3. Use millis() to measure time in each state, so the button is read even while lights are on.
  4. Debounce the pedestrian button in software (ignore changes shorter than 30 ms).
  5. Test it in Wokwi first, then build it with real LEDs and 220 Ω resistors.
  6. Write the state diagram into your README; interviewers like seeing the design before the code.

Make it stand out

  • Add a night mode where yellow blinks.
  • Run two crossing roads from one controller.

Put it on your resume

Implemented a traffic-light controller as a finite state machine in embedded C with non-blocking timing and a debounced pedestrian input.

Replace each [x] with a number you measured. Real numbers make a line believable.

Keep going

This project fits stage 3, “Digital logic and signals”, of the Foundation roadmap.

More Foundation projects

All 49 project ideas