After we successfully built a circuit to have a blinking green LED, we wanted to bring it to the next level.
First step: have alternating lights. It was quite easy, as we also had a Texas Instruments SN74LS04 inverter chip, we just connected it to 5V and GND, connected the output signal of the TLC555 to one of the inverters in the 74LS04 and got the inverted signal on the next pin, which then we could simply connect to another LED.
Next step: add a switch so select between stop
(red) and go
(white). No big thing, right? Add a switch, and then the output (clock
) of the TLC555 can go to the red (as before) or to the white LED. Simple. And does not work. Remember the inverter? It inverts the input for the first red LED (red1
) to get the signal for the second red LED (red2
), so as soon as we switch on the white LED (white
) the first red will be permanently off, so the second will be permanently on.
Luckily we also had the Texas Instruments SN74LS08 with 4 AND gates, so we could improve the logic. Put the switch to 5V instead of clock, and then AND the white state with the clock to get the white LED and the red state with the clock / inverted clock to get the two red LEDs. Basically the following:
white = go AND clock
red1 = stop AND clock
red2 = stop AND NOT clock
It should work, right? Well, no. If the switch is set to go then the AND gate will get 5V plus the clock signal to get the white LED input, but if the switch is set to stop, then the go line will be open, and in this case the output of the AND gate is not defined.
To solve it, we turned around the switch: not to switch 5V between stop and go, but switch go between 5V and GND. This way go was always in a defined state, and to get stop we just inverted go. This way we get our nice railway crossing light.
Of course we have set it up with a bunch of control lights: two LEDs blinking alternately to show the clock signal, as well as an addition red and white LEDs to show the state of the switch.