Traffic Light LED

Posted: September 21, 2013 by schoolpiclub in General News

20130921-162133.jpg

Our next project is trying out the OCR recipe for the Traffic Light LED’s.

It’s Saturday afternoon and Mrs H has managed to get the Traffic Lights up and running on her Raspberry. Mrs H did have a little trouble with the red light and had to tweak the recipe and swop the gpio settings. Mrs H swapped 3 to 11 and 25 to 14. This also meant changing the python code accordingly. This was the amended code:-

import time
import RPi.GPIO as GPIO
GPIO.cleanup()
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11,GPIO.OUT)
GPIO.setup(5,GPIO.OUT)
GPIO.setup(7,GPIO.OUT)
while True:
GPIO.output(11,GPIO.HIGH)
time.sleep(2)
GPIO.output(5,GPIO.HIGH)
time.sleep(2)
GPIO.output(5,GPIO.LOW)
GPIO.output(11,GPIO.LOW)
GPIO.output(7,GPIO.HIGH)
time.sleep(2)
GPIO.output(7,GPIO.LOW)
GPIO.output(5,GPIO.HIGH)
time.sleep(2)

I hope JW and LD have had chance to have a go! But if not it doesn’t matter because we have School Pi Club Monday lunchtime – cannot wait!

Advertisements

Comments are closed.