siltuz
Posts: 48
Joined: Thu May 16, 2013 8:08 pm

Problem with GPIO

Sun May 11, 2014 3:02 pm

Hi,

I finally got my hands on a breadboard, breakout & Ribbon, led's, resistors and wires, with the view of learning to use the GPIO... however for whatever reason there seems to be an issue, as even with this setup:
Image
I am unable to get the LED to light up at all
The code I used was:

Code: Select all

import RPi.GPIO as GPIO            # import RPi.GPIO module  
from time import sleep             # lets us have a delay  
GPIO.setmode(GPIO.BCM)             # choose BCM or BOARD  
GPIO.setup(24, GPIO.OUT)           # set GPIO24 as an output   
  
try:  
    while True:  
        GPIO.output(24, 1)         # set GPIO24 to 1/GPIO.HIGH/True  
        sleep(0.5)                 # wait half a second  
        GPIO.output(24, 0)         # set GPIO24 to 0/GPIO.LOW/False  
        sleep(0.5)                 # wait half a second  
  
except KeyboardInterrupt:          # trap a CTRL+C keyboard interrupt  
    GPIO.cleanup()                 # resets all GPIO ports used by this program  
How can I troubleshoot what is the issue? I don't have anything to measure volts or anything from the GPIO and I don't have the money to buy anything for it as I used all I could to get these parts.

suicidal_orange
Posts: 217
Joined: Sun Mar 16, 2014 10:56 am

Re: Problem with GPIO

Sun May 11, 2014 3:21 pm

First thing, are you sure the ribbon isn't connected backwards so you're connecting to GPIO9 and ground not the pins you think you are? It's an easy mistake to make when you're enthusiatically soldering your first breakout :)

If the ribbon is right are you sure the LED is connected the right way? One way it wont light up, the other it will.

If you've tried the LED both ways and still have no luck move the blue wire to pin one which is a constant 3.3v and it should light up, if not try the LED the other way round again.

If you still get no light I'd say your LED is either broken or needs more voltage than you're giving it - what made you choose a 330 ohm resistor?

siltuz
Posts: 48
Joined: Thu May 16, 2013 8:08 pm

Re: Problem with GPIO

Sun May 11, 2014 3:39 pm

suicidal_orange wrote:First thing, are you sure the ribbon isn't connected backwards so you're connecting to GPIO9 and ground not the pins you think you are? It's an easy mistake to make when you're enthusiatically soldering your first breakout :)

If the ribbon is right are you sure the LED is connected the right way? One way it wont light up, the other it will.

If you've tried the LED both ways and still have no luck move the blue wire to pin one which is a constant 3.3v and it should light up, if not try the LED the other way round again.

If you still get no light I'd say your LED is either broken or needs more voltage than you're giving it - what made you choose a 330 ohm resistor?
I am quite sure the ribbon is on the right way, and ive tried the LED both ways with the constant 3.3v as well but still no light... I've also tried this with around 10 LED's now. I chose the 330 ohm resistor just because the diagram I followed from http://raspi.tv/2013/rpi-gpio-basics-5- ... h-rpi-gpio did

User avatar
Burngate
Posts: 6048
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Problem with GPIO

Sun May 11, 2014 4:03 pm

330Ω should work with a red LED as in your Fritzing image - though other colours may be problematical. Some may require more than the 3.3v from the GPIO

You've not got the LED to light at all? Even from pin 1 - raw 3v3? Until you've got something out of the LED we can't progress much further!
It seems unlikely that all 10 LEDs are broken.
Could you try, using 5v, pin 2 or 4. If that doesn't work, we're maybe looking at something more fundimental - are they really plain LEDs, is the resistor really 330Ω

You say your ribbon is definitely the right way round - but there's no ribbon in that image (which I see is from that raspi.tv page), so I'm still suspicious that the problem might be to do with this.

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

Re: Problem with GPIO

Sun May 11, 2014 4:04 pm

Just to clarify.

You connect a LED and 330 ohm resistor in series between the 3.3V pin on the Pi and ground and it does not light?

siltuz
Posts: 48
Joined: Thu May 16, 2013 8:08 pm

Re: Problem with GPIO

Sun May 11, 2014 4:11 pm

Burngate wrote:330Ω should work with a red LED as in your Fritzing image - though other colours may be problematical. Some may require more than the 3.3v from the GPIO

You've not got the LED to light at all? Even from pin 1 - raw 3v3? Until you've got something out of the LED we can't progress much further!
It seems unlikely that all 10 LEDs are broken.
Could you try, using 5v, pin 2 or 4. If that doesn't work, we're maybe looking at something more fundimental - are they really plain LEDs, is the resistor really 330Ω

You say your ribbon is definitely the right way round - but there's no ribbon in that image (which I see is from that raspi.tv page), so I'm still suspicious that the problem might be to do with this.
The LED's that I have been using are red ones, and i've tested it raw, still no light at all.
Using the 5v pins there isnt any light either, the resistor and LED are both correct as far as I know.

I use the ribbon because I dont have any male to female cables only the male to male breadboard ones, the ribbon goes into a breakout board on the breadboard, if this is the issue, how can I test it without further equipment?



and joan, to clarify, yes

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

Re: Problem with GPIO

Sun May 11, 2014 4:18 pm

A photo of your set-up may help.

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: Problem with GPIO

Sun May 11, 2014 4:28 pm

What are the colour-codes on your 330ohm resistor?
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

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

Re: Problem with GPIO

Sun May 11, 2014 4:36 pm

Do you have a part number or link to the LED's that you are using?
Some LED's have resistors built in. If that is the case then adding an external resistor would be too much.
But don't try without a resistor if you don't know for sure as connecting voltage to a standard LED without a resistor would instantly destroy it.

Are you sure the resistor value is correct? 330 Ohms and not 330K Ohms or some other value? Use an ohm meter to check or tell what the color (colour) bands are.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

siltuz
Posts: 48
Joined: Thu May 16, 2013 8:08 pm

Re: Problem with GPIO

Sun May 11, 2014 4:57 pm

I'll post a picture of the setup soon, but I just realised I was actually using the wrong resistor, I was using orange orange orange gold when I thought it was orange orange brown gold. I have no orange orange brown for 330, but I have 165 ohm, 680 ohm and 820 ohm (among other random ones), would any of these be suitable? Maybe connecting the 5v and then the 680 ohm? or staying on 3v3 with the 165?
oh and there is no resistor with the LED as the pack it came in contained resistors

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: Problem with GPIO

Sun May 11, 2014 5:03 pm

Now you know what the likely problem was, I suggest you get back to testing from the fixed 3.3v on Pin 1 because that is what you will get from the programmable pins once you progress beyond this...
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

User avatar
MattHawkinsUK
Posts: 538
Joined: Tue Jan 10, 2012 8:48 pm
Location: UK
Contact: Website

Re: Problem with GPIO

Sun May 11, 2014 5:07 pm

The 680ohm should work. You could also use 2 165ohm resistors in series giving you 370.
My Raspberry Pi blog and home of the BerryClip Add-on board : http://www.raspberrypi-spy.co.uk/
Follow me on Google+, Facebook, Pinterest and Twitter (@RPiSpy)

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

Re: Problem with GPIO

Sun May 11, 2014 5:20 pm

Or two 680 Ohm in parallel to give 340 Ohm.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

siltuz
Posts: 48
Joined: Thu May 16, 2013 8:08 pm

Re: Problem with GPIO

Sun May 11, 2014 5:25 pm

still no luck from either straight 3v3 or the original setup
i went for the two 165's setup
pics:
Image
Image

suicidal_orange
Posts: 217
Joined: Sun Mar 16, 2014 10:56 am

Re: Problem with GPIO

Sun May 11, 2014 5:32 pm

siltuz wrote:oh and there is no resistor with the LED as the pack it came in contained resistors
Is this a pack of random LEDs from Maplin by any chance? I got one last weekend :lol:

If it is and you have a block with three LEDs like traffic lights I can tell you that this one will run without getting warm (due to getting too much power) on 3.3v with a 165ohm reistor and all the pins plugged in to the same strip of breadboard, with ground on the right if you're looking at the LED side.

Any joy?

siltuz
Posts: 48
Joined: Thu May 16, 2013 8:08 pm

Re: Problem with GPIO

Sun May 11, 2014 5:39 pm

suicidal_orange wrote:
siltuz wrote:oh and there is no resistor with the LED as the pack it came in contained resistors
Is this a pack of random LEDs from Maplin by any chance? I got one last weekend :lol:

If it is and you have a block with three LEDs like traffic lights I can tell you that this one will run without getting warm (due to getting too much power) on 3.3v with a 165ohm reistor and all the pins plugged in to the same strip of breadboard, with ground on the right if you're looking at the LED side.

Any joy?
it is precisely that pack, used the last of my dosh till payday on it :x
no joy whatsoever, is there any code or anything I can use to check if the GPIO is outputting?

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: Problem with GPIO

Sun May 11, 2014 5:42 pm

Looking at your 6.25pm image (in my timezone) it seems you are trying to program this LED by connecting it to Pin18/GPIO#24. Get back to basics and make sure you can light up the LED by connecting it and its limiting resistor(s) between the fixed 3.3v supply on Pin1 and a Ground pin - that has to work before it makes sense to try anything else.

Is the ribbon cable 'polarised' (with a cutout) where it enters the green circuit board on the breadboard? Is it possible that this connection has been reversed? I can't read the labelling from your picture - what do the labels on the top left and top right corners of the little green pcb say? [I know this has been asked before and you've said it's OK - but there is something wrong here that we need to help you clear up... ]
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

suicidal_orange
Posts: 217
Joined: Sun Mar 16, 2014 10:56 am

Re: Problem with GPIO

Sun May 11, 2014 5:45 pm

The easiest way to test is to use the 3.3v or 5v pin instead of a GPIO. GPIOs are just 3.3v pins with an off switch so I suggest you stick with the 3.3v for testing.

Once you know the LED and the rest of the circuit works you can worry about the GPIOs - they usually behave unless you've short circuited them.
DeeJay wrote:Is the ribbon cable 'polarised' (with a cutout) where it enters the green circuit board on the breadboard? Is it possible that this connection has been reversed? I can't read the labelling from your picture - what do the labels on the top left and top right corners of the little green pcb say? [I know this has been asked before and you've said it's OK - but there is something wrong here that we need to help you clear up... ]
The ribbon has a pink stripe which is in the corner of the Pi and the lable on the breakout at the pink end is 5v0 so it's not that :)

siltuz
Posts: 48
Joined: Thu May 16, 2013 8:08 pm

Re: Problem with GPIO

Sun May 11, 2014 5:54 pm

DeeJay wrote:Looking at your 6.25pm image (in my timezone) it seems you are trying to program this LED by connecting it to Pin18/GPIO#24. Get back to basics and make sure you can light up the LED by connecting it and its limiting resistor(s) between the fixed 3.3v supply on Pin1 and a Ground pin - that has to work before it makes sense to try anything else.

Is the ribbon cable 'polarised' (with a cutout) where it enters the green circuit board on the breadboard? Is it possible that this connection has been reversed? I can't read the labelling from your picture - what do the labels on the top left and top right corners of the little green pcb say? [I know this has been asked before and you've said it's OK - but there is something wrong here that we need to help you clear up... ]
In the picture the top left was 3v3 the top tight was 5v
If I am understanding the term polarised right, then the ribbon cable is (as in theres only one way to slot it onto the pcb).

trying it with 3v3 there is still no change in the LED

suicidal_orange
Posts: 217
Joined: Sun Mar 16, 2014 10:56 am

Re: Problem with GPIO

Sun May 11, 2014 6:01 pm

Is that with the "traffic light" one or one of the other random ones? I would test some others but all standard LEDs look the same but might have different requirements...

Actually there is another distinctive one - it's big and clear in colour, but instead of a flat or domed top the top is indented. This one is also happy with 3.3v and 165ohms.

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: Problem with GPIO

Sun May 11, 2014 6:09 pm

siltuz wrote: In the picture the top left was 3v3 the top [r]ight was 5v
On most adaptors I have seen I would expect both 3v3 and 5v to be adjacent at either the right or left.

Can you provide a link to the model of breadboard breakout adaptor you are using, please - maybe this adaptor is presenting the pins from the RPi onto the breadboard in an unexpected order?
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

siltuz
Posts: 48
Joined: Thu May 16, 2013 8:08 pm

Re: Problem with GPIO

Sun May 11, 2014 6:15 pm

DeeJay wrote:
siltuz wrote: In the picture the top left was 3v3 the top [r]ight was 5v
On most adaptors I have seen I would expect both 3v3 and 5v to be adjacent at either the right or left.

Can you provide a link to the model of breadboard breakout adaptor you are using, please - maybe this adaptor is presenting the pins from the RPi onto the breadboard in an unexpected order?
http://www.ebay.co.uk/itm/GPiO-Breakout ... 1177589910
suicidal_orange wrote:Is that with the "traffic light" one or one of the other random ones? I would test some others but all standard LEDs look the same but might have different requirements...

Actually there is another distinctive one - it's big and clear in colour, but instead of a flat or domed top the top is indented. This one is also happy with 3.3v and 165ohms.
that was with both traffic light and a random test of a couple of others... I don't think I have the indented one in mine, or atleast not that I can find

suicidal_orange
Posts: 217
Joined: Sun Mar 16, 2014 10:56 am

Re: Problem with GPIO

Sun May 11, 2014 6:31 pm

Hmm... silly suggestion but have you tried different resistors and jumper cables? It only takes one faulty component, it might not be the LED.

You have to have 3.3v for the Pi to boot and ground can't break so your problem is definitely on the breadboard somewhere

siltuz
Posts: 48
Joined: Thu May 16, 2013 8:08 pm

Re: Problem with GPIO

Sun May 11, 2014 6:34 pm

suicidal_orange wrote:Hmm... silly suggestion but have you tried different resistors and jumper cables? It only takes one faulty component, it might not be the LED.

You have to have 3.3v for the Pi to boot and ground can't break so your problem is definitely on the breadboard somewhere
I've tried different LED's, resistors and jumper cables from the packs, but if the whole pack is faulty then I don't know how to check them. In terms of it being one of the components, How can I check each component? they all come from separate places so if I need to send any back I have to know which thing it is

suicidal_orange
Posts: 217
Joined: Sun Mar 16, 2014 10:56 am

Re: Problem with GPIO

Sun May 11, 2014 7:47 pm

You sure you don't have a friend/relative with a multimeter? That would be easiest...

You can test the jumper cables by pretending you have a switch - unplug the jumper, run a script to set the pin as an input and low, and then when you connect the GPIO to 3.3v it should register as the switch being pressed.

If you have several of the same type of LED and don't mind possibly loosing one you could connect it straight from 3.3v to ground briefly (using just jumpers - you don't want to be touching it) the worst you will do is burn the LED out and make a bad smell (I've done this to a couple :oops:) but if it doesn't die you know that one works and can use it to test the resistors. Green LEDs seem to be the dimmest so I'd suggest one of them (they need more power)

Return to “Beginners”