1

Can you take a look at the attached circuit and code (below). It seems the green LED should blink but I'm not getting it to light up at all. Thoughts? Thanks so much!

Circuit: circuit diagram

Python code:

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)

GPIO.setup(12, GPIO.OUT)
GPIO.output(12, GPIO.LOW)

try:
    while True:
        GPIO.output(12, GPIO.HIGH)
        print "should be on"
        time.sleep(1)
        GPIO.output(12, GPIO.LOW)
        print "should be off"
        time.sleep(1)

except KeyboardInterrupt: # If CTRL+C is pressed, exit cleanly:
    GPIO.cleanup() # cleanup all GPIO`
  • 5
    A couple of things to check: is the LED correctly installed (LED's are polarized and need to be installed correctly) the longer leg should be to the right in the picture above, second, is the ribbon cable installed correctly - the easiest way to check this is to use a multimeter to test the power and ground pins. – Steve Robillard Jan 6 '18 at 13:49
  • 1
    There are a lot of "my LED is not blinking or glowing" types of questions in Raspberry Pi and Arduino exchanges. Most solutions are that the wiring does not match the LED polarity. An LED is a Light Emitting Diode so it is a diode which allows current to flow in only one direction. If your voltage source is not connected to the anode (long leg) and your ground is not connected to the cathode then the LED will not light because current will not flow. A resistor, such as you have, reduces the voltage and prevent damaging the LED. startingelectronics.org/beginners/components/LED – Richard Chambers Jan 6 '18 at 14:23
  • @joan my mistake, I mixed up the voltage drop calculations for the resistor size with the current flow. You are right, it is too much current which damages the LED. I can't seem to be able to edit the comment anymore. – Richard Chambers Jan 6 '18 at 15:46
  • 1
    @SteveRobillard ahhh... reversed the LED.. didn't know it was polarized. Thanks so much!! – user3058197 Jan 6 '18 at 15:51
  • In that case please answer your own question. – Steve Robillard Jan 6 '18 at 15:56
1

As the OP realized, the LED was not polarised correctly, which prevented the light from flashing.

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.