Python: Raspberry Pi: First project: LED Blinking

First project


This is an easy project that using the Raspberry Pi GPIO 40 pin to control the LED blinking with Python GPIO library.

I would not be going through the process of putting the wires together on the breadboard. Picture tells it all. Just remember to ground it and have a resistor.



I am using pin 4 for the LED

Code:


import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
while True:
    GPIO.output(24, True)
    print "Led On"
    time.sleep(3)
    GPIO.output(4, False)
    print "Led Off"
    time.sleep(2)