Instructables

Step 1: GPIO Pinouts

Here is a diagram of the GPIO pins on the Raspberry Pi.

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.

Step 2: Root account

In this Instructable I am only covering how to control the GPIO pins via a terminal window. To see how to control them via a web browser, click here.

Firstly you must login to your Raspberry Pi as root. This step will cover how to enable the root account, skip to the next step if you can already do this.

To enable the root account, login to your raspberry pi, then type "sudo -i" and hit Return / Enter. (you'll need to type your password in).
Then type "passwd root" and hit Return / Enter.
You will be asked to type a password, then confirm it.
It will say that the password was successfully changed.
Now you need to completely log out of your Raspberry Pi (Restarting it works as well :D), then login with:
Username: root
Password: Whatever you just set
 
Remove these adsRemove these ads by Signing Up
CaioP1 month ago

were is the gpio.sh text ? i dont see for download , please help me

CaioP1 month ago

here is the gpio.sh text ? i dont see for download , please help me

CaioP CaioP1 month ago

where * , sorry for my bad english

Kamilon2 months ago

You can fairly easily create logic level shifters to use sensors etc that are not 3.3v natively. I have a blog post about doing just that:

http://blog.kamilon.com/?page_id=263

spafruit11 year ago
When i run the scrip it says:

./gpio.sh: line 34: echo: write error: Operation not permitted
drcurzon (author)  spafruit11 year ago
Hi there.
Are you running the script as root?
Many thanks, Dan.
I'm having the same problem as garym1957..............
I have found my problem, the problem was difficult to find but easy to fix. It had to do with things called carriage returns, google them. I copied drcurzon's gpio.txt into notepad on my Windows machine, I then used ftp to upload the file to my Rasp Pi

Well, Linux and Windows handle carriage returns("enter or return button") differently, and that was the source of my errors
drcurzon (author)  7equivalents1 year ago
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.
Hi,
I was wondering if you needed to install any packages or python libraries before doing these steps.
Thanks!
drcurzon (author)  fergusondavid62 years ago
Hi there.
Nope, nothing extra to the instructable needs to be done :)
If you need any help, or have any problems, just ask :D
Daniel.
Hi again,
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!
ajf350d2 years ago
Just started doing 'something interesting' with my Pi, and been following this and the other instructables for web control.

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.
drcurzon (author)  ajf350d2 years ago
Hi there.
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.
Just the LED lights as per the suggestion in this Instructable.
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.
Capture.JPG
cadams212 years ago
This may sound like a dumb question i am a idiot when it comes to external technology but how do you use a gpio and can i use it to control if a cord that's connected or to a PC also can it check what information is passing threw the cord if so how.
garym19572 years ago
I'm having trouble getting your .sh file to execute. Are'nt shell scripts supposed to have #!bin/sh or something at the top of the file?
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.
drcurzon (author)  garym19572 years ago
Hi there,
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.
drresearch2 years ago
According to this page http://elinux.org/RPi_Low-level_peripherals , the GPIO pins are NOT 5v tolerant and are NOT over-voltage protected,
drcurzon (author)  drresearch2 years ago
That's correct - they're 3.3v data connections.
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.
miicchhii2 years ago
BBerastegui2 years ago
First, THANK YOU for all these tutorials ;)

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.
drcurzon (author)  BBerastegui2 years ago
Hi there,
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 know the command syntax :P

I just mean that its working but just in reverse. With number 1, it turns off, and with number 0 turns on.

Thanks !
Maybe you wired the LED to 3V3 instead of ground?
I remember reading specs of an early expectations of what they wanted the GPIO to do and I'm fairly sure they were limiting EVERYTHING to 3V3, though it now looks like SOME of the pins can handle 5V.

You may find this page useful.

http://www.raspberrypi.org/archives/384
This is one of the mods on the Raspberry Pi Forum (Abishur to be exact ;-) ) There is only 1 pin that can take 5V and that's the one labeled 5V! To be precise it's connected to the 5V rail so it can either source or sink 5 volts. If you try and connect 5V to any of the regular GPIO pins, you are going to fry your pi!
drcurzon (author)  abishur2 years ago
Nice :D Thanks for that - saved me trying it and damaging my Pi.
Thanks, Daniel.
drcurzon (author)  Dream Dragon2 years ago
Hey, thanks for the comment.
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.