Friday, July 27, 2012

Raspberry Pi Simple LED flash

So, although you can't see it, that LED is changing between on and off every second.

The LED is connected into pin 11 via a 1K2 ohm resistor and the other LED leg goes to 3v3 (pin 0). It wasn't difficult to do once I was on an unfiltered Internet connection (to install the necessary software onto Raspbian-17/5/2012).

First I had to:
sudo apt-get install python-dev
This is to install the Python development libraries - Python is already installed but the I/O library needs the headers and stuff to build. Next I downloaded RPi.GPIO-0.3.1a.tar.gz then:
tar zxf RPi.GPIO-0.3.1a.tar.gz
cd RPi.GPIO-0.3.1a
sudo python setup.py install
And we also need a program, which looks like this:
import RPi.GPIO as GPIO
import time 
 
GPIO.setmode(GPIO.BOARD) 

print "Setup pin 11"
GPIO.setup(11, GPIO.OUT)

while true:
  print "Set output false"
  GPIO.output(11, False)
  time.sleep(1)
 
  print "Set output true"
  GPIO.output(11, True)
  time.sleep(1)

All of this is based on the instructions here, although they are very slightly out of date. 

Simple!

0 Comments:

Post a Comment

<< Home

Newer›  ‹Older