0

EDIT: The problem ended up being that the ribbon cable going to my breadboard was rotated 180º. I was taking this into account, but doing so incorrectly. Once I correctly labeled the rotated pinout, I was able to detect input on the proper pins.


I have a circuit setup according the the image below (just the button to GPIO 4 part, not the LED).

However, when I push the button, I see input on GPIO pin 22, not pin 4. In fact, it doesn't matter what GPIO pin I connect the button to. Whether it's #4, 26, 20, 12, 6, etc. I keep getting input only on pin #22.

I'm using the gpio read [pin#] command to debug this, as well as this command to output the pin value every second:

while true; do gpio read [pin#]; sleep 1; done;

(I'm using a Raspberry Pi 3 Model B+)

enter image description here

3
  • 1
    Post a photo of your wiring.
    – CoderMike
    Commented Sep 25, 2021 at 6:38
  • I think you have enough experience at SO to be aware of the importance of an SSCCE. What you have here is not that, meaning your problem is not reproducible with the information given. Consequently, if you are correct about what you have done and what happens, then there is no diagnosis for this problem besides "broken hardware" or some other general catch-all for explaining things with no other explanation.
    – goldilocks
    Commented Sep 25, 2021 at 14:18
  • 1
    @goldilocks: You're right, thank you for saying that. I did not provide enough information for anyone to help me. It did end up being a silly hardware issue. My ribbon cable was rotated 180º.
    – Luc
    Commented Sep 25, 2021 at 18:04

1 Answer 1

3

You might begin by verifying the pin numbers. WiringPi uses a numbering system that is different from other libraries. A good source for wiringpi pin numbers is the Raspberry Pi Pinout website. Clicking on a pin - for example GPIO 4 will reveal the numbering system specific to the wiringpi library. You should also take a look at the documentation for the gpio utility as it explains "how things work", and even an option for using the more conventional BCM_GPIO pin numbers should you prefer that.

You should perhaps also familiarize yourself with some of the history of the wiringpi library, and some of its idiosyncrasies. In particular, wiringpi is no longer maintained by its author, Gordon, but another team has set up a GitHub site to carry on with the project he started. FWIW, Gordon explained the logic behind his choice of pin number assignments - it makes sense to me, but perhaps not to everyone.

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