In this Instructable I will show you how to get a very basic GPIO system working with your Raspberry Pi.
For this I will focus on simply controlling an LED.
NOTE: For controlling GPIO via a web browser, click here.
Remove these ads by
Signing UpStep 1: GPIO Pinouts
Please note that the DNC connections are actually connected on the board - so don't put voltage on them :D
For example;
To turn pin 7 of the header connector on, you set GPIO 4 high.
Note: You can find another pinout image, here.








































Visit Our Store »
Go Pro Today »




./gpio.sh: line 34: echo: write error: Operation not permitted
Are you running the script as root?
Many thanks, Dan.
Well, Linux and Windows handle carriage returns("enter or return button") differently, and that was the source of my errors
http://www.instructables.com/id/Web-Control-of-Raspberry-Pi-GPIO/
Let me know how it goes.
Regards, Daniel.
I was wondering if you needed to install any packages or python libraries before doing these steps.
Thanks!
Nope, nothing extra to the instructable needs to be done :)
If you need any help, or have any problems, just ask :D
Daniel.
Thanks for your quick response. Could you please tell me the pin numbers that I would connect the positive leg of the LED to and the pin number I would connect the negative leg of the LED to.
Do I connect the positive leg to the 3.3.v pin, and the negative to any GPIO pin? Do I need any resistors?
Thanks!
I don't understand the wiring you have done for the LED in this Instructable though?
Can you clarify it or show a diagram?
it looks like you have a connection to the USB port.
I have never done electronics but this seems odd and from other googling I cannot find a similar diagram.
Thanks.
On one of the steps of this instructable is a diagram showing the pinout of the raspberry pi's gpio pins.
The LED is connected to a GPIO output.
What are you trying to power with the GPIO?
Daniel.
The picture at the top of this page is the wiring I meant.
I couldn't understand how it was wired in the Pi itself.
I've also attached the image for clarity and highlighted the area that confused me.
Also, the variable "response" throws an error near the beginning of the script...
": not a valid identifier `response
...and some other errors before an ugly death. Unexpected end of file.
Is ther a corrected version of this script around? I'm not a shell expert at all.
I've been running the script for a while and haven't had a problem.
That said, have you tried the following instructable? (It's the updated version of GPIO).
http://www.instructables.com/id/Web-Control-of-Raspberry-Pi-GPIO/
Let me know how it goes.
Regards, Daniel.
You'd need a driver board to do anything big with them.
That said - I haven't had any issues with 5v on them.
Daniel.
Second, I'm having a ridiculous problem...
Why is the led turning ON when i do "echo "0" > /sys/class/gpio/gpio21/value" and turning OFF when I do "echo "1" > /sys/class/gpio/gpio21/value" ?
I don't know why it can be, and im getting a little bit mad, now I'm programming a little bit.
Thanks again.
I don't know if you've just accidentally typed it incorrectly here, or whether you've used in with the pi as well, but the commands should be;
To Turn off:
echo "0" > /sys/class/gpio/gpio21/value
To Turn on:
echo "1" > /sys/class/gpio/gpio21/value
It's my fault in the way I wrote it in the instructable.
You only need to encapsulate the 0, or 1 in speech marks, not the entire command.
Hope this helps, and have fun with it :D
Daniel.
I just mean that its working but just in reverse. With number 1, it turns off, and with number 0 turns on.
Thanks !
You may find this page useful.
http://www.raspberrypi.org/archives/384
Thanks, Daniel.
I think you're right about the 5V connections to SOME of the pins, they also said that they wanted to keep the input voltages as low as possible to save power.
I think I'll stick with 3.3v to be safe though. (Until I accidentally put 5v on it :D)
Thanks, Daniel.