0

enter image description hereI have been trying to right my first physical script, to simply light an LED. I HAVE BEEN DOING HOBBY ELECTRONICS FOR A WHILE, and lighting an LED is simple.

Wanted to use Pi to light LED, but I can't get voltage across led. I have literally copied code off web, word for word, and still can't get output.

Is their something wrong with the board? Or is this a lot more complicated than I thought it was?

#RPi.GPIO is the library for Rassberry-pi GPIO functions(python) I need to import to utilize functions.
import RPi.GPIO as GPIO
import time

#Setup GPIO using Board numbering
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)

#Project pin configuration
GPIO.setup(12, GPIO.OUT) 

#Configure digital output
GPIO.output(12, GPIO.HIGH)

All I'm trying to do is get the LED tto light up. I'm not getting voltage across LED or resistors.

1.] Updated and reinstalled RPi.GPIO, no of the pins work.

2.] This is the second development board I have bought in an attempt to learn how to program, and it feels like another ripoff already. I had the Intel Galileo before this, and couldn't get far because it couldn't run the simple programs they lied were so easy. This feels like the same thing all over again, like I need a Phd. to get a light to turn on.

  • Please add your code. (and where you put your wires if possible) – Ethan Oct 24 '17 at 8:05
  • #RPi.GPIO is the library for Rassberry-pi GPIO functions(python) I need to import to utilize functions. import RPi.GPIO as GPIO import time #Setup GPIO using Board numbering GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) #Project pin configuration GPIO.setup(12, GPIO.OUT) #Configure digital output GPIO.output(12, GPIO.HIGH) – Iam Pyre Oct 24 '17 at 8:09
  • The most likely error is using the wrong pin. We need a photo to be able to help you. – joan Oct 24 '17 at 8:57
  • I think it's damaged. I type the code right in the shell and it still doesnt work. try different pins, still doesn't work. – Iam Pyre Oct 24 '17 at 9:27
  • Edit your question and add the code there, it's unreadable in the comments! And to use capital letters means SCREAMING! – MatsK Oct 24 '17 at 12:15
4

No, it's not more complicated. Getting your first program to run (and work) can sometimes be a bit confounding.

It could be my eyes, but it looks like you're connected to pin 4 (+5v) and pin10 (gpio15). I may be wrong.

I suggest a super-simple first test. Connect the led+ (anode, longer pin) to pin 2 or 4 (+5v) and led- (cathode, shorter lead) to pin 6 (ground). Make sure you have a current limiting resistor (250 to 500 ohms) in series with the led (either pin). It should light up whenever power is applied (software independent). This will confirm you the have the led connected correctly and the board is getting power. If it doesn’t light, try reversing the LED connection).

Once that works, move the connector from pin 2 or 4 to pin 12 (gpio 18). Since your using ‘GPIO.setmode(GPIO.BOARD)’, the code is using the pin numbers rather than the i/o numbers. Run your code again and see if it works.

If you think your board is at fault, you could try a different GPIO. GPIO 3 on pin 5 for example. This would tell you just the single GPIO is damaged. If the chip is fried, I bet you would get a error message or your code would load or run. Next you could try reading the pin in your code after setting it with something like this:

GPIO.input(12)

if GPIO.input(12):
  print("Pin 12 is HIGH")
else:
  print("Pin 12 is LOW")

This will give some insight in what the pin is actually doing.

Here's a quick reference on connecting LEDs. Maybe this will help. Vs is the output voltage of the Pi: 3.3v Vf is the LED voltage, typically 1.7v for a red led. If is the desired current through the LED (see data sheet), a safe starting value would be 5 ma.

Therefore: Rs = (3.3v - 1.7v) / 0.005a = 320 ohms

LED Reference

Good luck!

  • Based on what your saying, maybe my wiring is wrong. As an electronics hobbyist, I'm used to tying cathode to negative terminal(Which would be current flow) anode to ground. What your saying sounds like the complete opposite of what I wired. Maybe I'm not comprehending the whole "positive voltage" thing. – Iam Pyre Oct 24 '17 at 19:33
  • "I'm used to tying cathode to negative terminal(Which would be current flow) anode to ground." -> This implies there are two terminals, negative and ground. That is not correct thinking WRT a simple LED circuit. Whatever you have been doing before this, you have gotten very, very confused. The anode of an LED should be connected to the positive terminal, the cathode to the negative. Consider "negative" and "ground" to be synonymous in this context. Negative and positive are relative. If ground is 0V, and you are using a +3.3V supply, then ground is the negative terminal. – goldilocks Oct 24 '17 at 23:41
1

Your code worked fine on my Pi3

Check that the negative pin (shorter pin) on the LED connects to ground (black lead in image, pin 6).

Check that the output is connected to the correct pin 12 (yellow lead). https://pinout.xyz/pinout/pin12_gpio18

I'm using a 220 ohm resistor between the output and the LED.

enter image description here

0

If your wire coloring scheme is right, you connected the plus (red) to ground and vice versa. I see a red wire on GND (pin 6) and a black wire on pin 12.

enter image description here

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.