1

That's my current structure:

GPIO GPIO 2

The short metal of the LED (-) is connected to GND, and the longer (+) is in the port 26. This black "thing" (I don't know the name) is connected to my Pi B+ by a gray cable.

My code:

import RPi.GPIO as GPIO
import time                           

GPIO.setmode(GPIO.BOARD)
GPIO.setup(26, GPIO.OUT)
delay = 2

def turnon(pin):
    GPIO.output(pin, 1)
    return

def turnoff(pin):
    GPIO.output(pin, 0)
    return

while(True):      
    turnon(26)
    time.sleep(delay)
    turnoff(26)
    time.sleep(delay)

I run this code as root (because it orders me to do that). The problem is that when I execute this code nothing happens. I don't get any errors and the LED doesn't blink.

The Pi I bought was this one: http://www.amazon.com/CanaKit-Raspberry-Ultimate-Starter-Components/dp/B00G1PNG54

  • RESISTOR!!!! You have to connect a resistor serially to your LED or you will fry the pi! – Bex Feb 13 '15 at 11:39
  • Thanks. The other guy said about the resistors too. I used some LEDs without the resistor for seconds, I don't know if I ruined a pin, I'll run a test later. The Pi is safe, it's still working and the chip is ok, no visual issues. – JChris Feb 13 '15 at 15:26
0

From the pictures. It appears that you have the cable connected to the board incorrectly. Normally the red stripe on a ribbon cable indicates pin 1. Pin 1 on the Pi is on the SD card end of the board. You can see the pin numbers in this photo, and the orientation of the cable in this picture (this is a board similar to yours produced by Adafuit called the Pi Cobbler).

  • Just wondering. The Blue LEDs works normal, bigger in the 3.3 + and smaller in the 3.3 -. But other colors like green didn't work, and the yellow made a little sound and a tiny light in the hole and the Pi reboot =p Maybe those need the resistor? – JChris Feb 13 '15 at 2:35
  • The little sound usually means that you have killed it (let out the magic blue smoke). That is what can happen when you don't use a resistor. – Steve Robillard Feb 13 '15 at 2:39
  • Killed the LED, not the board/role, right? The LED is cheap, I'll buy new ones anyway. – JChris Feb 13 '15 at 2:47
  • You probably didn't kill the board but you may have killed a pin. – Steve Robillard Feb 13 '15 at 2:49
  • pin, you mean, that role? Well, is it cheap to buy a new board like that? Anyway, I'll search about resistors now and try to use that role again to see if it still works – JChris Feb 13 '15 at 2:51

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.