Traffic Lights Challenge

Did you know?

Traffic Lights
An embedded system is a computer system with a dedicated function within a larger mechanical or electrical system, often with real-time computing constraints.

A burglar alarm, an in-car cruise control system, a speedometer on a bike, a traffic lights control system are all examples of embedded system.

One application of computing is to create the algorithms used by these control systems. For this challenge we will focus on a traffic lights system.

Our Traffic Lights


Our system consists of two traffic lights used at a crossing.

The diagram below describes the sequence that these traffic lights have to follow:
traffic-light-sequence

We have started the code to control the first traffic light.

Your Challenge


Tweak this code to control the second traffic light. The second traffic light sequence should match the one described in the diagram above. However both traffic lights cannot be green at the same time!

Extension


Check this article to see how “smart” traffic lights help control the flow of traffic more effectively.

Did you like this challenge?

Click on a star to rate it!

Average rating 3 / 5. Vote count: 5

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: , ,