I got myself an LED bicycle traffic light but after a few days of having all 3 lights on at the same time i got a bit bored with it. Time to get it working as it was meant to!
In this house that means hooking it up to a microcontroller and as usual i used Arduino.
The controller outputs 5 volts control signals and the traffic light needs 230v AC so i had to add a triac board to get things working.
Then for the software: it took me half an hour to write. I have 3 switches, one for each light so i can manually switch on any combination of leds. But i also wanted 3 automatic modes: normal Dutch 3 state operation, blinking yellow and the 4 state operation that’s being used in the UK.
The only problem was that there are only 8 combinations that can be made with 3 switches and 7 of them are needed for the manual color selection.
That left me with one setting to select 3 different modes. The solution was simple: the switch that is the last one to be switched off selects which of the programs run in automatic mode.
So now i ended up with the following features:
– Any switch in the on position lights up the respective led
– Switching red off with yellow and green already off starts 3 state mode, that’s green, yellow, red and back to green
- Switching yellow off with red and green already off starts yellow blinking mode, which is used here in the Netherlands to indicate the traffic light is not in use
- Switching green off with red and yellow already off starts 4 state mode, that’s green, yellow, red, red+yellow and then back to green.
One day later i added two more automatic programs:
- Switching all leds on and then off in the order red-yellow-green activates ‘Knight rider’ mode where the leds behave like the leds on the front of Kitt
- Switching all leds on and then off in the order green-yellow-red activates ‘Blink all’ where all of the leds blink at once. As suggested by mr. Tarzan.
And that’s another toy finished!
Music by Luke Dyton ( https://www.youtube.com/user/LDUKMusic )
Arduino code (no ‘Blink all’ / ‘Knight rider’) : https://pastebin.com/ezqQYq0n
Arduino code including the new modes: https://pastebin.com/EGeHRZ6C
Do whatever you want with the Arduino code. It’s all yours!
Post time: Jun-14-2017