4
\$\begingroup\$

I'm completely new to hardware in general. I just got a raspberry pi and was messing around trying to get an LED to light up.

I have everything wired like the picture below. I am using a 330ohm resister, which I believe is bigger therefore ok then what is required.

enter image description here

also (sorry this is my first time using any program to draw a circuit)

enter image description here

The program runs successfully, but no light comes on. I know the LED is good as I've tested it on the arduino. Anybody care to explain my wiring fault?

root@raspberrypi:/home/pi# cat test.py
#!/usr/bin/python
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)

GPIO.output(11, True)

Changing to GPIO pin 0 results

Traceback (most recent call last):
  File "test.py", line 5, in <module>
    GPIO.setup(0, GPIO.OUT)
RPi.GPIO.InvalidChannelException: The channel sent is invalid on a Raspberry Pi
root@raspberrypi:/home/pi#
\$\endgroup\$
4
  • \$\begingroup\$ Have you confirmed the GPIO is actually at 3.3V? (or whatever the Rpi uses) Also, a schematic would be better than the picture, it's difficult to see what's connected to what. \$\endgroup\$
    – Oli Glaser
    Aug 12 '12 at 19:54
  • \$\begingroup\$ Are you sere you don't need to add a pull-up resistor? Try connecting the resistor to +5V and invert the diode. \$\endgroup\$ Aug 12 '12 at 20:29
  • \$\begingroup\$ That looks okay (I'm assuming the anode of the LED actually connects to the GPIO in the bottom diagram) Did you test the pin is set to a high (e.g. 3.3V) level when you run your program? Is the LED the right way round? \$\endgroup\$
    – Oli Glaser
    Aug 12 '12 at 20:29
  • \$\begingroup\$ What color is the LED? \$\endgroup\$ Aug 21 '12 at 20:47
3
\$\begingroup\$

Try reversing the led. The longer lead should be connected to the gpio pin and not ground. Also are you using the correct pin? Some are disabled

\$\endgroup\$
3
\$\begingroup\$

If your Fritzing diagram is correct, you've connected your LED to the S_CLK pin of the SPI bus, which is also known as pin 11. Try using one of the general purpose pins (GPIO0-7) rather than the special-purpose pins.

\$\endgroup\$
2
\$\begingroup\$

Try using the Pin 4 (the bottom row, 4th pin, it is marked as #4 in Fritzing). Then change your program to:

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM) # Note the GPIO.BCM here, and not GPIO.BOARD
GPIO.setup(4, GPIO.OUT)
GPIO.output(4, True)

And run your program with "sudo", like this: sudo python ./my_prog.py.

\$\endgroup\$
2
\$\begingroup\$

You're using Broadcom GPIO numbering for the channel but specified GPIO.BOARD as the numbering mode. Either change the numbering mode to GPIO.BCM or use 23 as the channel number.

\$\endgroup\$

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.