Aug 23, 2012

Control LEDs with Raspberry Pi


Using an old hard drive cable, I built a GPIO breakout cable then proceed to make an LED blink... a classic 'Hello World' of electronics.  I followed this diagram for the connections.


Plug the wires and follow these steps:
  1. Boot the Raspberry Pi
  2. Login as root (embrace your dark side)
  3. Getting ready to output in GPIO4:
  4. $ echo "4" > /sys/class/gpio/export
    $ echo "out" > /sys/class/gpio/gpio4/direction
  5. Turn GPIO4 on:
    $ echo "1" > /sys/class/gpio/gpio4/value
  6. Turn GPIO4 off:
    $ echo "0" > /sys/class/gpio/gpio4/value


Tada!

I'm now using WiringPI c++ library.  Here's a good reference to get started at Limina.Log. And a good pins reference table.

3 comments: