Makershpere 2016

 I have been Voluntered to present at Mary Mags Makersphere in preston.

it started small but I decided to upscale it a little bit.....

Why turn on one LED when you could go to the extreme and turn on floodlights!

at this point I thought I think I need to scale it back a bit,So 240v led bulbs at .5w is a bit better.

 

I wanted to get the "pupils" to build the boards by soldering them up ,Slight issue with health and safety, aparantly I am not allowed to burn people with soldering irons.

Traffic Light Boards Parts List

  

Resistors £2.54

Pack of 100

http://www.ebay.co.uk/itm/111201206601?_trksid=p2057872.m2749.l2649&var=410262387751&ssPageName=STRK%3AMEBIDX%3AIT

 

Vero board  Pack of 10 £5.49

http://www.ebay.co.uk/itm/121017749921?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

 

Leds £2.39 x 3 ( Red,Amber,Green)(£7.17)

http://www.ebay.co.uk/itm/381217917569

Total £15.20 + Time and Soldering

Traffic Light Code (Easy)

 #---------------------------------------------------------------------#
# #
# Pi Traffic Lights - Created By Dave Gallop - @DGA110P #
# Easy #
#---------------------------------------------------------------------#
import RPi.GPIO as GPIO
import time
import sys
import os # for clearing screen #### os.system("clear") ####
import signal # use to allow clean exit on ctrl -c
def cleanup_gpio(signal, frame):
print "learing All Leds to Off" #cheating by missing C for clearing (run in terminal to see what I mean)
GPIO.cleanup()
sys.exit(0)

# Install signal handler to cleanup GPIO when user sends SIGINT
signal.signal(signal.SIGINT, cleanup_gpio)

#sets up GPIO pins as outputs
GPIO.setwarnings(False) #to disable warnings
GPIO.setmode(GPIO.BOARD) # Sets board gpio pins
#PIN_LEDS=[12,13,15]

GPIO.setup(12,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)


on = 0 # used to turn led on by using "on" rather than High or 1 ( might need swapping depending on board used )
off = 1 # used to turn led off by using "off" rather than Low or 0 ( might need swapping depending on board used )

# start clean all leds off

GPIO.output(12,off)
GPIO.output(13,off)
GPIO.output(15,off)

os.system("clear")# used to clear screen and start from the top
print "Starting Clean ,Turning all lights off"
print "Program will start in 5 Seconds"

time.sleep(5) # waits five seconds
# define pins to traffic light colours
red = 12
amber = 13
green = 15


# safe start set to red

GPIO.output(red,on)# red turn on

while True:
GPIO.output(red,on)
# Wait for 2 seconds
time.sleep(2)

# Turn on the yellow LED
GPIO.output(amber,on)
# Wait for 2 seconds
time.sleep(2)

# Turn off the red LED
GPIO.output(red,off)
# Turn off the amber LED
GPIO.output(amber,off)

# Turn on the green LED
GPIO.output(green,on)
# Wait for 2 seconds
time.sleep(10) # waits ten seconds to allow car to go thru

# Turn off the green LED
GPIO.output(green,off)

# Turn on the yellow LED
GPIO.output(amber,on)
# Wait for 2 seconds
time.sleep(2)

# Turn off the yellow LED
GPIO.output(amber,off)

# Turn on the red LED
GPIO.output(red,on)
# Wait for 2 seconds
time.sleep(2)

Traffic Light Code (Medium)

 #---------------------------------------------------------------------#
# #
# Pi Traffic Lights - Created By Dave Gallop - @DGA110P #
# Medium #
#---------------------------------------------------------------------#
import RPi.GPIO as GPIO
import time
import sys
import os # for clearing screen #### os.system("clear") ####
import signal # use to allow clean exit on ctrl -c
def cleanup_gpio(signal, frame):
print "learing All Leds to Off" #cheating by missing C for clearing (run in terminal to see what I mean)
GPIO.cleanup()
sys.exit(0)

# Install signal handler to cleanup GPIO when user sends SIGINT
signal.signal(signal.SIGINT, cleanup_gpio)

#sets up GPIO pins as outputs
GPIO.setwarnings(False) #to disable warnings
GPIO.setmode(GPIO.BOARD)
#PIN_LEDS=[12,13,15]

GPIO.setup(12,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)


on = 0 # used to turn led on by using "on" rather than High or 1 ( might need swapping depending on board used )
off = 1 # used to turn led off by using "off" rather than Low or 0 ( might need swapping depending on board used )

# start clean all leds off

GPIO.output(12,off)
GPIO.output(13,off)
GPIO.output(15,off)

os.system("clear")# used to clear screen and start from the top
print "Starting Clean ,Turning all lights off"
print "Program will start in 5 Seconds"

time.sleep(5) # waits five seconds
# define pins to traffic light colours
red = 12
amber = 13
green = 15


verbose = True # set True to print to screen False not to print to screen
if verbose :print "verbose is on ,Screen output will display"
else :print "Verbose is off no screen display"

# safe start set to red
print "Safe Start setting both sides to Red"
GPIO.output(red,on)# red turn on


cars = 10 # amount of cars to pass through ,change to suit ,larger amount will allow more cars smaller fewer cars
print cars," Cars allowed to pass"

while True:
if verbose :print " North Red Light On" # if verbose = True then print ,if verbose = False then ignore rest of line..
GPIO.output(red,on)
# Wait for 2 seconds
time.sleep(2)

# Turn on the yellow LED
if verbose :print " North Amber Light On"
GPIO.output(amber,on)
# Wait for 2 seconds
time.sleep(2)

# Turn off the yellow LED
if verbose :print " North Red & Amber turn off"
GPIO.output(red,off)

# Turn off the red LED
GPIO.output(amber,off)

# Turn on the green LED
if verbose :print " North Green Light On"
GPIO.output(green,on)
# Wait for 2 seconds
time.sleep(cars)

# Turn off the green LED
if verbose :print " North Green Light Off"
GPIO.output(green,off)

# Turn on the yellow LED
if verbose :print " North Amber Light On"
GPIO.output(amber,on)
# Wait for 2 seconds
time.sleep(2)

# Turn off the yellow LED
if verbose :print " North Amber Light Off"
GPIO.output(amber,off)

# Turn on the red LED
if verbose :print " North Red Light On"
GPIO.output(red,on)

# Wait for 2 seconds
time.sleep(2)

Traffic Light Code (Advanced)

 #---------------------------------------------------------------------#
# #
# Pi Traffic Lights - Created By Dave Gallop - @DGA110P #
# Advanced #
#---------------------------------------------------------------------#
import RPi.GPIO as GPIO
import time
import sys
import os # for clearing screen #### os.system("clear") ####
import signal # use to allow clean exit on ctrl -c
def cleanup_gpio(signal, frame):
print "learing All Leds to Off" #cheating by missing C for clearing (run in terminal to see what I mean)
GPIO.cleanup()
sys.exit(0)

# Install signal handler to cleanup GPIO when user sends SIGINT
signal.signal(signal.SIGINT, cleanup_gpio)

#sets up GPIO pins as outputs
GPIO.setwarnings(False) #to disable warnings
GPIO.setmode(GPIO.BOARD)
#PIN_LEDS=[0,11,12,13,15,16,18,22,24,26,8,10]

GPIO.setup(12,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)

GPIO.setup(24,GPIO.OUT)
GPIO.setup(26,GPIO.OUT)
GPIO.setup(8,GPIO.OUT)

on = 0 # used to turn led on by using "on" rather than High or 1 ( might need swapping depending on board used )
off = 1 # used to turn led off by using "off" rather than Low or 0 ( might need swapping depending on board used )

# start clean all leds off
GPIO.output(12,off)
GPIO.output(13,off)
GPIO.output(15,off)

GPIO.output(24,off)
GPIO.output(26,off)
GPIO.output(8,off)

os.system("clear")# used to clear screen and start from the top
print "Starting Clean ,Turning all lights off"
print "Program will start in 5 Seconds"

time.sleep(5) # waits five seconds
# define pins to traffic light colours north(n) and south (s) eg redn is red North
redn = 12
ambern = 13
greenn = 15

reds = 8
ambers = 26
greens = 24

verbose = True # set True to print to screen False not to print to screen
if verbose :print "verbose is on ,Screen output will display"
else :print "Verbose is off no screen display"

# safe start both north and south set to red
print "Safe Start setting both sides to Red"
GPIO.output(redn,on)# red(N)orth turn on
GPIO.output(reds,on)# red(S)outh turn on

cars = 10 # amount of cars to pass through ,change to suit ,larger amount will allow more cars smaller fewer cars
print cars," Cars allowed to pass"

while True:
if verbose :print " North Red Light On" # if verbose = True then print ,if verbose = False then ignore rest of line..
GPIO.output(redn,on)
# Wait for 2 seconds
time.sleep(2)

# Turn on the yellow LED
if verbose :print " North Amber Light On"
GPIO.output(ambern,on)
# Wait for 2 seconds
time.sleep(2)

# Turn off the yellow LED
if verbose :print " North Red & Amber turn off"
GPIO.output(redn,off)

# Turn off the red LED
GPIO.output(ambern,off)

# Turn on the green LED
if verbose :print " North Green Light On"
GPIO.output(greenn,on)
# Wait for 2 seconds
time.sleep(cars) # Cars set above

# Turn off the green LED
if verbose :print " North Green Light Off"
GPIO.output(greenn,off)

# Turn on the yellow LED
if verbose :print " North Amber Light On"
GPIO.output(ambern,on)
# Wait for 2 seconds
time.sleep(2)

# Turn off the yellow LED
if verbose :print " North Amber Light Off"
GPIO.output(ambern,off)

# Turn on the red LED
if verbose :print " North Red Light On"
GPIO.output(redn,on)
# Wait for 2 seconds
time.sleep(2)

# South Lights
if verbose :print " South Red Light On"
GPIO.output(reds,on)
# Wait for 2 seconds
time.sleep(2)

# Turn on the yellow LED
if verbose :print " South Amber Light On"
GPIO.output(ambers,on)
# Wait for 2 seconds
time.sleep(2)

# Turn off the yellow LED
if verbose :print " South Red & Amber turn off"
GPIO.output(reds,off)

# Turn off the red LED
GPIO.output(ambers,off)

# Turn on the green LED
if verbose :print " South Green Light On"
GPIO.output(greens,on)
# Wait for 2 seconds

time.sleep(cars)

# Turn off the green LED
if verbose :print " South Green Light Off"
GPIO.output(greens,off)

# Turn on the yellow LED
if verbose :print " South Amber Light On"
GPIO.output(ambers,on)
# Wait for 2 seconds
time.sleep(2)

# Turn off the yellow LED
if verbose :print " South Amber Light Off"
GPIO.output(ambers,off)

# Turn on the red LED
if verbose :print " South Red Light On"
GPIO.output(reds,on)
# Wait for 2 seconds
time.sleep(2)

Homepage

Search