kiancrowley
Posts: 12
Joined: Fri Jan 16, 2015 11:40 pm

GPIO pins do not work

Fri Jan 16, 2015 11:48 pm

Hi everybody,

I'm rather new to my Raspberry Pi and I've been trying to set up the GPIO pins to light up a simple LED. Using a Pi Cobbler Breakout Kit, I've attached it to a breadboard and wired up one LED with a 220 ohm resistor. However, every attempt to light the LED has been a failure. For some reason it won't light up no matter what I try to do. I've wired it up to pin #17 and then connecting it to ground as well. I also know to run the code through root. I've been using this code:
{
import RPi.GPIO as GPIO
from time import sleep

GPIO.setmode(GPIO.BCM)

GPIO.setup(17, GPIO.OUT)

while True;
GPIO.output(17, True)
sleep(2)
GPIO.output(17, False)
sleep(2)
}

I would greatly appreciate if you had any tips to solve this. I just can't seem to get any output whatsoever from the GPIO pins on this raspberry pi.
Thanks,
Kian

klricks
Posts: 7154
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: GPIO pins do not work

Sat Jan 17, 2015 12:20 am

Are you sure the ribbon cable on the cobbler (or RPi) is on correct way? Seems to be a common error where the cable is wrong way around.
Post a picture.
Last edited by klricks on Sat Jan 17, 2015 1:24 am, edited 1 time in total.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: GPIO pins do not work

Sat Jan 17, 2015 12:30 am

Have you got the LED round the right way? Cathode (short leg), flat on the packaging to GND, anode to the GPIO pin (with the resistor in series with the LED).
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: GPIO pins do not work

Sat Jan 17, 2015 1:50 am

The first test (to check you are doing things right) is to run the LED from a 3v3 pin to Gnd (through a resistor).

This tests LED polarity and your u derstanding of the GPIO pin layout.
Doug.
Building Management Systems Engineer.

kiancrowley
Posts: 12
Joined: Fri Jan 16, 2015 11:40 pm

Re: GPIO pins do not work

Sat Jan 17, 2015 8:13 am

IMG_0958-2.JPG
the wiring of the LED through pin 17 and to GND
IMG_0958-2.JPG (45.6 KiB) Viewed 1189 times
I have the LED the right way and I believe the ribbon cable is the right way as well. The gray cable is towards the SD and it only goes in one way in the cobbler. I also tried the 3.3V and nothing happened. I've attached a couple pictures.

Note: Before finding the right configuration, I realized I had the ribbon cable on the wrong way on the pi and tried running code through that. However, I've long since corrected that. Maybe I could've damaged something?

Thank you all for the quick responses.
Attachments
IMG_0959-2.JPG
RPi to ribbon cable connection, gray cable towards SD card
IMG_0959-2.JPG (26.32 KiB) Viewed 1189 times

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO pins do not work

Sat Jan 17, 2015 8:16 am

If the Pi boots there will be 3V3 available on the 3V3 pins on the expansion header (pins 1 and 17).

What colour LED? Some have a higher forward voltage requirement. Try a 5V rail pin (e.g. pins 2 or 4).

P_Monty
Posts: 57
Joined: Sat Dec 27, 2014 2:45 pm
Location: Wiltshire, UK

Re: GPIO pins do not work

Sat Jan 17, 2015 8:27 am

I can't be sure from the picture, but I think the wiring needs a slight change. The yellow wire and resistor are ok, but it looks like the led and the other wire are all on the same strip of the breadboard, effectively bypassing the led. I'd try moving the wire one row along (it looks like it's in row 29, move it to 28 or 30) and move the end of the led nearest it to the same row. Leave the leg of the led nearest the resistor where it is.

kiancrowley
Posts: 12
Joined: Fri Jan 16, 2015 11:40 pm

Re: GPIO pins do not work

Sat Jan 17, 2015 9:05 am

P_Monty: You are correct! I can't believe I could have overlooked that, I've been using breadboards for about a month now. I feel silly.
Thank you so much!

P_Monty
Posts: 57
Joined: Sat Dec 27, 2014 2:45 pm
Location: Wiltshire, UK

Re: GPIO pins do not work

Sat Jan 17, 2015 9:06 am

No problem - things like that are easily done...

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: GPIO pins do not work

Sat Jan 17, 2015 9:28 am

Perhaps an illustration of "Linus's Law'': "Given enough eyeballs, all bugs are shallow.''

From The Cathedral and the Bazaar: Eric Raymond

(But kudos to @P_Monty for eyeballing it!)

Return to “Troubleshooting”