1

I got a RPi 2 model B v1.1 a while ago, and I am having way too much trouble trying to change the states of the GPIO pins. I have tried RPi.GPIO with a simple Python script and WiringPi in the command line. I have also gone in and changed the states as per step 6 of this resource.

I'm not running anything fancy, and this whole process began as just a simple test to get used to RPi.GPIO scripts, but now I'm starting to think something is wrong. None of the simple scripts I try to run from a variety of sources have any effect on GPIO states; for example, when I tried to change the state manually with Wiringpi in the command line, it would show the commands having an effect in the readall command, but there would be no actual effect on output (the LED wouldn't turn on or off).

I have tried everything I can think of, using different ports, LED's, trying a script with a button, using WiringPi commands from the Command line, going in as a superuser and assigning states. Nothing is working. Any help or ideas would be greatly appreciated.

  • 2
    I am going to assume the actual question is how do I switch a LED on and off. How have you connected the LED to the Pi? Could you edit your question to include those details (including the LED colour, resistor value used, and GPIO used). A photo will be helpful. – joan Nov 24 '15 at 22:13
  • 2
    As joan says, the only way someone else can confirm you aren't doing anything wrong is to see all the details. E.g., there are several different numbering systems used to refer to the pins, which can cause confusion, and a diagram or photo is necessary to rule that out. – goldilocks Nov 25 '15 at 4:13
  • @goldilocks Given that gpio readall sees the change I think you are right in assuming there may be a mismatch between the GPIO the OP is using and the GPIO the OP thinks they are using. – joan Nov 25 '15 at 9:08
1

I learned to control the Raspberry Pi 2's GPIO by following this tutorial: https://learn.sparkfun.com/tutorials/raspberry-gpio They covered Python, command line, C programming with the wiringPI library from the command line and from the Geany. I was able to control my boards IO lines and I2C devices.

1

Are you using the GPIO as the pi user (or 'root' superuser) - if not I think you may need to add the user name you are using to the gpio group to have permission to access the gpio pins. First you can check which groups your username is a member of with the (standard *nix) following command (which for the default pi user gives):

pi@raspberry ~ $ groups

pi adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi

However for me (I use the same user name on my PCs and on my Pis):

stephen@raspberry ~ $ groups

stephen games users

I need to add myself to some of those, like this:

stephen@raspberry ~ $ su

Password: < no visible text >

root@raspberry:/home/stephen# adduser stephen gpio

Adding user `stephen' to group `gpio' ...

Adding user stephen to group gpio

Done.

root@spock:/home/stephen# exit

stephen@raspberry ~ $

Obviously I could do with adding myself to sudo, games, video and audio as well but this will give you the idea... Note that being added to/removed from a group will not take effect immediately without further steps, but will do upon your next login!

  • I'd reiterate what @goldilocks mentioned in the comment to your question - I was testing my second hand RPi 2 B and I ran into the disparity between the numbers that WiringPi uses and the numbers marked on the Pimironi case (which reflect the Broadcom IC pin numbering) - I found this web page useful for the B+ and 2 pinouts. Of course after studying that the output from 'gpio readall` made much more sense...! – SlySven Nov 25 '15 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.