Over a million developers have joined DZone.

Advanced Raspberry Pi Traffic Lights Simulator

DZone's Guide to

Advanced Raspberry Pi Traffic Lights Simulator

This more advanced take on a traffic light simulator has an improved architecture and downloads schedules from a remote server.

· IoT Zone ·
Free Resource

My previous post about Raspberry Pi traffic lights introduced a simple traffic lights simulator. I developed the solution further and came out with a more advanced version that has a better architecture, more flexible design, and support for traffic lights schedules that are automatically downloaded from a remote server.

I published the new and more advanced version of my traffic lights project where the software side is more advanced and architecturally more generalized. You can find a link to my work on GitHub below.

Source code available! To get the whole source code with explanations and guidance please go to my GitHub repository: WindowsIotTrafficLights.

The solution includes the following:

  • Source code of all components, as well as simple online documentation about hardware and software pieces
  • Windows 10 IoT Core background service and UWP application projects (UWP also has form-based traffic lights implemented)
  • Separate library with granulated classes that hold traffic light logic
  • Different implementations for interfaces needed to switch traffic lights
  • Automatic update and loading of traffic lights schedules from a remote server
  • Two traffic light schedules (one for regular traffic lights and another one for blinking yellow)
  • PHP script to randomly serve the traffic light schedules.

Feel free to dig around in my code and try it out. Also feel free to make improvements to the code and give me feedback.

Great Example for Kids

You can be evil and screw with your kids' brains with this sample. Just try to explain what it means to blink the yellow light, but do it through guiding questions so they really have to think. Maybe I'm not very good on discussions like, this but here is my example that you can improve.

You: How do you say to the computer, "I want to blink the yellow light?"
Kid: You tell it to do it — just blink the yellow light!
(You make the yellow light blink and the red one constantly on)
You: Is it really enough?
Kid: Hmm... umm... ooo.... no?
You: So, what else do I have to do?
Kid: You have to turn out the green and red lights!
You: Right you are. But now, what's blinking?
Kid: The yellow light blinks!
You: It's actually two steps, just remember what we did with red and green.
Kid: Aaah! We turn the yellow light on and off!
You: Yes, right! You just earned some candy.


raspberry pi ,traffic ,iot ,windows 10 iot core

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}