beakersoft
Posts: 28
Joined: Thu Apr 26, 2012 4:35 pm

Re: Really Simple Hardware Control

Thu Apr 26, 2012 5:39 pm

Hi,

I've been playing about with my pi, and would like to try and interface with some other hardware, unfortuanly I'm not sure where to start. I have seen the Wiki with the GPIO pins, and the example code but i'm a bit lost with the pin outs.

Could someone help me out just turning an LED on and off using the pins, just something really simple like that should get me started. I just need to know the way to run the wires, and how to drive that from the os

Cheers!

User avatar
SN
Posts: 1014
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
Contact: Website

Re: Really Simple Hardware Control

Thu Apr 26, 2012 6:07 pm

monjpc has posted a really simple single led example on here - try searching for it
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?


Techmeology
Posts: 30
Joined: Wed Mar 28, 2012 8:52 pm
Contact: Website

Re: Really Simple Hardware Control

Fri Apr 27, 2012 12:07 am

If you want even simpler control, use the interface in /sys/class/gpio. So if you use GPIO 25 (that's pin 1-22 - top row, third from the right):

su root
echo 25 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio25/direction
echo 1 > /sys/class/gpio/gpio25/value #set gpio 25 to high (3.3 V)
echo 0 > /sys/class/gpio/gpio25/value #set gpio 25 to low (0 V)
echo 25 > /sys/class/gpio/unexport #undoes the export operation in the second line

As for the circuit, something like that described here works: http://elinux.org/RPi_Tutorial.....rcuit.29  I found it useful to solder together a few "GPIO header cables" - basically 2x2 2.54 mm PCB headers soldered to wire with a solid core at the end (useful for plugging into a breadboard). I made three (1 for 3v3 and 5v, one for 0v, and one for some more GPIO pins).
Check out cool stuff I'm doing, e.g my PIC Programmer for the Raspberry Pi: http://www.techmeology.co.uk/rpipic/

beakersoft
Posts: 28
Joined: Thu Apr 26, 2012 4:35 pm

Re: Really Simple Hardware Control

Fri Apr 27, 2012 11:14 am

Thanks those sound great, i'll have a go at them this weekend

User avatar
rew
Posts: 423
Joined: Fri Aug 26, 2011 3:25 pm

Re: Really Simple Hardware Control

Sat Apr 28, 2012 9:16 am

If you want to skip the "connecting up the LED" part of the experiment, use GPIO 16.

If you make it low, the OK led will light up. If you make it HIGH, the LED goes off.

There is something in the kernel that is turning the led back on every second or so. But other than that it works.
Check out our raspberry pi addons: https://www.bitwizard.nl/shop/

Return to “Beginners”