Skip to content

Traffic Control Classroom Activity


Programmers will have to come up with code to control the traffic lights and not cause an accident. While doing so, they learn programming concepts and how mistakes in their programs, can impact others significantly.

People Needed

  • 1 volunteer as Traffic Light 1
  • 1 volunteer as Traffic Light 2
  • 1+ volunteers as programmers
  • 3+ volunteers as vehicles

Placement of People

Positioning of voluters

  • Blue is programmers (control box). Audience should positioned so that they see both traffic lights.
  • Red is Traffic Light 1
  • Green is Traffic Light 2

Goals and Instructions

  • Programmers are to come up with the code to control the traffic lights.
  • Vehicles will go through one light and circle back around to the other light.
  • Each mistake (or traffic collision) that they make means that they take the previous version of code and make corrections in the next version.
    • To make this more challenging, programmers can be fired (and replaced with new programmers) if they make too many mistakes (or cause too many collisions).
  • Ideally use a chalkboard or dry erase board for this so that the versioning differences can be seen.
    • If running out of board space, previous versions can be erased. Do not erase the very first version. Once completed, this will allow a full comparison and what was done between the first and final version.
  • Instructor will be “the internet”. If the programmers get stuck, they can ask the internet the question that they have.
    • To make this more challenging, limit the number of questions that can be asked.
  • Traffic lights will perform one action per command.
    • To make this more challenging, “Light on” and “Light off” can be two separate commands.
traffic, traffic light, traffic light, programmer exercise
Back to top