Easy Relay 4 - Python example

#!/user/bin/python

import RPi.GPIO as io
import time

io.setmode(io.BCM)

# the relays have io numbers 16,17,22,23 when connected via the 2x20 header
# if you wire manually via the 8-pin header then these numbers can be different
rel1 = 16
rel2 = 17
rel3 = 22
rel4 = 23

# set pins to output mode
io.setup(rel1, io.OUT)
io.setup(rel2, io.OUT)
io.setup(rel3, io.OUT)
io.setup(rel4, io.OUT)

# turn each relay on/off for a second, repeating 10 times
a = 1
while (a<=10) :
    a = a + 1
    io.output(rel1, True)
    time.sleep(1)
    io.output(rel1, False)
    io.output(rel2, True)
    time.sleep(1)
    io.output(rel2, False)
    io.output(rel3, True)
    time.sleep(1)
    io.output(rel3, False)
    io.output(rel4, True)
    time.sleep(1)
    io.output(rel4, False)