Circuit Diagram
Part 1
To install the Python development stuff we need.
sudo apt-get install python-dev
sudo apt-get install python-pip
sudo pip install RPi.GPIO
After starting the python interpretor, here are the commands to setup GPIO and light a single LED...
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
GPIO.output(4, True)
GPIO.output(4, False)
Part 2
Here are the stop light commands...
import time
GPIO.setup(17, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)
while True :
GPIO.output(22, True)
time.sleep(5)
GPIO.output(22, False)
GPIO.output(17, True)
time.sleep(2)
GPIO.output(17, False)
GPIO.output(4, True)
time.sleep(5)
GPIO.output(4, False)
CTRL-C to stop the while loop
Here is what should be in the rapidblink.py file...
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
GPIO.setup(17, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)
import time
while True :
GPIO.output(4, True)
time.sleep(.1)
GPIO.output(4, False)
GPIO.output(17, True)
time.sleep(.1)
GPIO.output(17, False)
GPIO.output(22, True)
time.sleep(.1)
GPIO.output(22, False)
GPIO.output(17, True)
time.sleep(.1)
GPIO.output(17, False)
CTRL-C to stop the script
Here is what should be in the ledoff.py file...
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
GPIO.setup(17, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)
GPIO.output(4, False)
GPIO.output(17, False)
GPIO.output(22, False)