- Python 3
Tiny traffic light on a breadboard controllable with a button.
Python 3 code to control the traffic light with a button.
x-python-script - 2.49 kB - 12/31/2015 at 01:17
Finished version with a minor drawback
I had to move the buttons control pin from Pin 2 to Pin 8 because the pins 2 & 3 have a built-in pull resistance which I didn't know by the time I was making the projects layout.
The Python code as it is in its current state, checks the status of the button every 0.5s.
This is just an emergency solution because in the initial state of the code, the button was checked several hundred times a second (no sleep-function) which led to an issue where you press the button and the status variable changes its state to fast and therefore you ended up with weird signals.
Connect any GND pin to an empty minus-Rail on your breadboard
I prefer to use pin 39 on my RPi2B to have more structure
Connect your LEDs
Connect your Button