4

I'm a rookie with Raspberry Pi and electronics in general. I was able to get my LED to turn on when I plug it into the breadboard but i'm unable to get it to respond via Python or wiringPi. The LED currently turns on as soon as there is power to the Pi.

With wiringPi i've tried this and nothing happens:

$ gpio -g mode 4 out
$ gpio -g write 4 0
$ gpio -g write 4 1

I've also tried running this code with python via $ sudo python test.py

test.py:

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(4,GPIO.OUT)
print "LED on"
GPIO.output(4,GPIO.HIGH)
time.sleep(1)
print "LED off"
GPIO.output(4,GPIO.LOW)

Any idea's on what i'm doing wrong and why I can't get software to talk to my LED?

I tried switching the ribbon the other way on my Pi so here's some updated pictures. With the updated pictures i've tried this via the command line:

$ gpio -g mode 21 out
$ gpio -g write 21 0
$ gpio -g write 21 1

enter image description here

enter image description here

Piotr Kula
  • 17,307
  • 6
  • 65
  • 104
Catfish
  • 193
  • 8

1 Answers1

3

With the help of @joan she identified that I had my ribbon cable on backwards.

The white stripe on the ribbon needs to be on the same side as the SD card of the Pi like in this picture:

Correctly placed ribbon cable

I also had to make sure that my positive leg of the LED was connected to the resistor and the negative side was on the negative rail as in this picture:

Correctly placed resistor

James Taylor
  • 289
  • 1
  • 3
  • 13
Catfish
  • 193
  • 8