1

Hi i am new to this raspberry pi. I am trying to light up LED it works fine on pin 1 with 3.3V. then I am trying to use pin7 and pin11 both but it fails to light. I already checked the GIPO setup for python and circuit both many times....

 import RPi.GPIO as GPIO ## Import GPIO Library
 GPIO.setmode(GPIO.BOARD) ## Use BOARD pin numbering
 GPIO.setup(7, GPIO.OUT) ## Setup GPIO pin 7 to OUT
 GPIO.output(7, True) ## Turn on GPIO pin 7
 GPIO.cleanup()

I think there must be some problem with my LED or resistance I am using 160ohm resistance.

pls help with this...will this resistance work with LED and GPIO pins voltage...

thanks in advance....

  • 2
    GPIO voltage is also 3.3 volt, so the led should light up. Could you post a picture of how you connected it? – Gerben Jun 1 '14 at 19:06
  • The voltage for LEDs vary, though most draw abotu 0.2A in current - for example, if it is a Red or Yellow LED, you might blow it up due to too much voltage - for info, see this page – Wilf Jun 1 '14 at 23:19
  • 2
    I have a feeling the GPIOs may be being turned off when the script exits, but I don't have a Pi to hand to test and usually do a manual cleanup when I expect scripts to exit. – user8894 Jun 2 '14 at 17:15
  • 1
    @manankhh Adding the time.sleep(10) before the GPIO.cleanup() should work. cleanup() is essentially a way of resetting the GPIOs after you are done using them. – user8894 Jun 2 '14 at 21:05
  • 1
    Also try the interactive python prompt sudo python and type in this script one line at a time, then you'll see the LED light up as soon as you call GPIO.output(7, True) – francis Jun 3 '14 at 11:24
2

Make sure the LEDs are oriented correctly. LEDs (Light Emitting Diodes) only allow current through one way. Try flipping them.

diagram

1

You need to setup pin11 as well so your modified code would be:

import RPi.GPIO as GPIO ## Import GPIO Library
GPIO.setmode(GPIO.BOARD) ## Use BOARD pin numbering
GPIO.setup(7, GPIO.OUT) ## Setup GPIO pin 7 to OUT
GPIO.output(7, True) ## Turn on GPIO pin 7
GPIO.setup(11, GPIO.OUT) ## Setup GPIO 11 to OUT
GPIO.output(11, False) ## Set GPIO 11 to False
  • 1
    I doubt this is the issue, OP claims neither pin 7 or 11 work and that the LED only works when connected the 3.3v – user8894 Jun 2 '14 at 17:11

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.