3D Traffic Lights

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:

We have started the code to control the first traffic light, through we have only completed the sequence to animate the first traffic light..

Method #1: Using Selection (If Statements)

(Use Google Chrome to preview this animation)

Right Click on the animation to change the view point (rotate camera angle).

Method #2: Using Iteration (For Loops)

Your Challenge

Tweak this code to control change the pattern both traffic lights. The traffic lights sequences should match the sequences described in the diagram above. However both traffic lights cannot be green at the same time!

Find out more…

To learn more about all the instructions you can use in GlowScript/VPython, use this on-line documentation.


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 4.8 / 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: , , ,