Tags:
tag this topic
create new tag
view all tags
---+ Traffic light simulator The Raspberry Pi (see [[Raspberry Pi Description]]) is the embedded system we use for our course. It can connect to the outside world through different types of interfaces. The most simple one is the connection through GPIO (General Purpose I/O) pins which are logic levels that can be input or output. When these pins are programmed as outputs, then they can drive LEDs (Light Emitting Diodes) and switch them on or off. Since lighting a single LED is not exactly spectacular we prepared a simulation of traffic lights. Imagine a road crossing where you have traffic lights on both roads. When the traffic light is green on one road it must be red on the other. The traffic lights are in this state for some time to make a good number of cars pass the crossing. Then the green light turns to yellow while the light on the other road is still red. This is a short phase just allowing the cars, which are already on the crossing to clear it. Then we keep both lights on red for a short period as a safety phase, before switching the other traffic light to green, again for a longer period. There are therefore the following phases: <table border="1" cellpadding="0" cellspacing="0" id="table1" rules="all"> <tbody> <tr> <td bgcolor="#ffffff" valign="top">Traffic Light 1</td> <td bgcolor="#ffffff" valign="top">Traffic Light 2</td> <td bgcolor="#ffffff" valign="top">Period</td> </tr> <tr> <td bgcolor="#edf4f9" valign="top">green</td> <td bgcolor="#edf4f9" valign="top">red</td> <td bgcolor="#edf4f9" valign="top">long</td> </tr> <tr> <td bgcolor="#ffffff" valign="top">yellow</td> <td bgcolor="#ffffff" valign="top">red</td> <td bgcolor="#ffffff" valign="top">short</td> </tr> <tr> <td bgcolor="#edf4f9" valign="top">red</td> <td bgcolor="#edf4f9" valign="top">red</td> <td bgcolor="#edf4f9" valign="top">short</td> </tr> <tr> <td bgcolor="#ffffff" valign="top">red</td> <td bgcolor="#ffffff" valign="top">green</td> <td bgcolor="#ffffff" valign="top">long</td> </tr> <tr> <td bgcolor="#edf4f9" valign="top">red</td> <td bgcolor="#edf4f9" valign="top">yellow</td> <td bgcolor="#edf4f9" valign="top">short</td> </tr> <tr> <td bgcolor="#ffffff" valign="top">red</td> <td bgcolor="#ffffff" valign="top">red</td> <td bgcolor="#ffffff" valign="top">short</td> </tr> </tbody> </table> When running the program on the Raspberry Pi or on the Arduino, these phases can be observed. The whole program can be implement as a simple state machine. ... and here you see the traffic light simulator in action: <img alt="trafficLight.png" height="569" src="%ATTACHURL%/trafficLight.png" title="trafficLight.png" width="558" /> -- %USERSIG{UliRaich - 2017-10-06}% ---++ Comments %COMMENT%
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
png
trafficLight.png
r1
manage
478.7 K
2017-10-09 - 12:11
UnknownUser
gz
trafficLight.tar.gz
r1
manage
4.9 K
2017-10-11 - 16:04
UnknownUser
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r3 - 2017-10-11
-
uli
Home
Site map
AFNOG web
Embedded_Systems web
IoT_Course_English web
IoT_Course_French web
Main web
Sandbox web
TWiki web
Embedded_Systems Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
E
dit
A
ttach
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback