Page 1 of 1
Re: Please explain GPIO like I'm five
Posted: Tue Apr 17, 2012 6:40 pm
by jfedor
Hi,
I got my Pi today and I'm incredibly excited.
I'd like to connect a pushbutton (or a switch) to the board and read its state. From what I understand that's what the GPIO pins can be used for. I've seen that there's a sysfs interface to GPIO and I think I can manage that part, but what about the actual physical connections. Two wires come out of the switch, should I connect one of them to one of the GPIO pins and the other to GND? Is that it? Do I need resistors and whatnot? I know absolutely nothing about electronics and I'd rather not fry my shiny new Pi.
Thanks.
Re: Please explain GPIO like I'm five
Posted: Tue Apr 17, 2012 7:15 pm
by naicheben
Re: Please explain GPIO like I'm five
Posted: Tue Apr 17, 2012 7:42 pm
by jfedor
I spent half of today on that wiki, I don't know how I missed that.
Thank you.
Re: Please explain GPIO like I'm five
Posted: Tue Apr 17, 2012 7:53 pm
by naicheben
I know how you feel! If I hadn't read about this article here I would not have found it on the Wiki. It's a big problem I think. Hopefully we can sort it out in time.
Re: Please explain GPIO like I'm five
Posted: Tue Apr 17, 2012 8:34 pm
by Gert van Loo
Easiest if you connect one pin of your switch to GPIO0 or GPIO1, the other side to ground. That is because those two pins already have an 1800 Ohm pull-up resistor. That is a resistor to the 3.3V supply which pulls the pin high unless you press the button which makes it go low. So button press is LOW, button release is HIGH.
Assume you are using GPIO0 from your unix prompt type:
'sudo sh'
'echo 0 >/sys/class/gpio/export'
'echo in >/sys/class/gpio/gpio0/direction'
'cat /sys/class/gpio/gpio0/value'
Repeat the last command with the button pressed and not pressed.
To come back to your normal prompt type 'exit'
Good luck!
Re: Please explain GPIO like I'm five
Posted: Tue Apr 17, 2012 11:40 pm
by jfedor
Thank you for your reply!
The GPIO0 pin you're talking about would be the second pin from the left in the bottom row of the header, correct? The nomenclature is a bit confusing to me, it seems there's a separate numbering scheme for the SoC's pins and for the board's pins.
Re: Please explain GPIO like I'm five
Posted: Wed Apr 18, 2012 11:22 am
by texy
Re: Please explain GPIO like I'm five
Posted: Wed Apr 18, 2012 1:13 pm
by jfedor
Yeah, this one I managed to find on my own. That's where the confusion comes from. You'll notice how in the diagram on the right, sixth pin in the bottom row is marked as GPIO0? And yet I'm pretty sure the one Gert meant was the one marked "I2C0_SDA"/"BCM2835 GPIO0-ALT0" in one of the tables (a different pin).
Re: Please explain GPIO like I'm five
Posted: Wed Apr 18, 2012 1:29 pm
by meltwater
Can"t wait to update the Easy GPIO stuff with some RPi code.
And get the rest of the articles done (the alpha-numeric display in particular).
Got nothing to test with yet though
Glad it is useful…will see about trying to link it better perhaps (DONE: linked from Getting Started section).