Traffic lights project
This exercise illustrates a general technique in digital logic. Entire binary sequences may be stored in a ROM which has a counter attached to its address lines. As the counter progresses though the count sequence (which can be any length), the binary values at that address will appear on the ROM’s output. I have set this project several times in a lab setting to give to students a better understanding about what can be accomplished using memory.
In the associated .CIRC file you will find eight l.e.d.s of different colors set up as if they were traffic lights at a standard road intersection. There is a North/South set of lights which controls traffic moving down the page. There is also an East/West set of lights controlling traffic travelling horizontally. There are also walk/don’t walk lights. White/orange for walk/don’t walk respectively
How does the memory help to control traffic flow?
Look into the ROM which is basically empty. At each address you will find two hexadecimal digits, each representing four (4) bits. b3b2b1b0. For both of the hexadecimal bits, b0 controls the red light of the N/S and E/W sets. b1 controls the yellow light, and the green light is controlled by the third bit b2. The second hexadecimal digit controls the N/S set whereas the first hex digit (on the left at each location in memory) controls the E/W set.
We are going to fill the ROM with hexadecimal numbers which cause the traffic lights to “change” as the counter increments and runs through all the addresses.
Example: right-click the ROM and bring up the hex editor. Sometimes, we will want a safety period where the lights are red & red – this would be after a “green” on one of the sets of lights. What we need from the memory to do this is 0001 0001 in binary, or in hexadecimal that would be “1116”. Leaving the counter at zero put 1116 into the first and second memory location. Do you see red & red? Now put 0001 0100 (“1416”) into the third memory location, and, using the manual clock push-button, increment the counter. You should see red & green. OK? Now, let’s keep the first two values but delete the “14” and compose a proper sequence.
So the rest is up to you! You have 16 ticks to compose a sequence which imitates a looped sequence that controls traffic. You saw my demonstration. Change it to the European standard which lights the red and amber lights for one period before a green.
Fix the walk/don’t walk lights.
The walk light associated with the E/W set of lights should be at “walk” if and only if the E/W light is red. Because the E/W traffic stream is the one the pedestrians are crossing. This is controlled by bit 3, and logical “1” will set the light to “walk”. If you murder pedestrians, I’ll be having words with the DMV.
Go European.
When a light is about to go green, most of Europe alerts the drivers to this by lighting both red and yellow (or “amber” as they would say) for a short time. European cars are tiny, underpowered and use a stick shift, so “red & amber” is a signal that means “get ready to go” and appears immediately before a “green”, for a short time. 1 tick.
Take a week, a .CIRC file with the ROM suitably filled out to control a European intersection. Use the text tool for your name and ID. Repeat memory values if you need a longer sequence than one tick of the counter. Please don’t disturb the counter. Right-click the ROM to edit its content. No save is necessary. Attach a screenshot and the .CIRC file to your email. Thanks.