Ladder board + python part 2

Further to previous posts on the ladder board,  controls all the 8 main LEDS on the board,  Ihave put these in order so they all light up but then turn off, one by one in order. see comments to see which code corresponds to which LED,  you will need Gordon Hendersons Ladderboard to make this work.


import RPi.GPIO as GPIO
import time


# su[ress warnings


GPIO.setup(7, GPIO.OUT)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(12, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
GPIO.setup(16, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)
GPIO.output(7, True) # blue 1
GPIO.output(11, True) # red 2
GPIO.output(12, True) # red 1
GPIO.output(13, True) # yellow 2
GPIO.output(15, True) # yellow 1
GPIO.output(16, True) # green 2
GPIO.output(18, True) # green 1
GPIO.output(22, True) # blue 2

#turn off sequentially


GPIO.output(11, False) # red 2


GPIO.output(12, False) # red 1


GPIO.output(13, False) # yellow 2


GPIO.output(15, False) # yellow 1


GPIO.output(16, False) # green 2


GPIO.output(18, False)# Green 1


GPIO.output(22, False) # Blue 2


GPIO.output(7, False) #blue 1


We can assign the pin numbers to variables

add the following code to the above


blue1 = 7
GPIO.output(blue1, True)

this allows us more control if we do this for all the LEDs its the same as setting the globals up (see the rtb code blocks) so we can use the variables and don’t need to work out which pin is which.

The delay is there so we know it works properly

In time it should be possible to store the numbers in a data block and then read this back accordingly.