Pi – Blink LED Python Script

A very simple python script to blink an LED 5 times for one second each time. GPIO17 (pin 11) is used to drive the lamp with a 470ohm resister between pin 11 and the lamp. DNC (pin 9) is used as the ground lead.

Screen Shot 2013-10-29 at 12.12.30 AM

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)
# blink GPIO17 5 times
for i in range(0,5):
        blink(11)
GPIO.cleanup()

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