Blink multiple LEDs script

This script blinks multiple LEDs in sequence. Driver pins on the GPIO are 11, 13, 15 and 19 with pin 9 acting as the ground. There’s a 470 ohm resister between driver pins and the lamp.

Screen Shot 2013-10-28 at 9.31.35 PM

The speed can be adjusted by modifying the “time.sleep(.1)” directive in the blink function. Changing it to ‘1’ will result in a one second on, one second off blinking lamp. ‘.1’ is much quicker and more entertaining to watch.

import RPi.GPIO as GPIO

GPIO.cleanup()

import time
# blinking function
def blink(pin):
        GPIO.output(pin,GPIO.HIGH)
        time.sleep(.1)
        GPIO.output(pin,GPIO.LOW)
        time.sleep(.1)
        return
# to use Raspberry Pi board pin numbers
GPIO.setmode(GPIO.BOARD)
# set up GPIO output channel
GPIO.setup(11, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
GPIO.setup(19, GPIO.OUT)
# blink GPIO17 50 times
for i in range(0,5):
        blink(11)
        blink(13)
        blink(15)
        blink(19)
GPIO.cleanup()

One thought on “Blink multiple LEDs script

Leave a reply below!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s