Skip to main content
2 of 2
Commonmark migration

RGB LED is not lighting up

I connected an RGB LED(common anode) via the GPIO, and tried to get it to light up, but for some reason when I run the command, the LED does not light up. Here's the code I'm using

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)

GPIO.setup(11, GPIO.OUT)
GPIO.output(11,1)
GPIO.setup(13, GPIO.OUT)
GPIO.output(13,1)
GPIO.setup(15, GPIO.OUT)
GPIO.output(15,1)

try:
    while(True):
        request = raw_input("RGB:")
        if(len(request) == 3):
            GPIO.output(11, int(request[0]))
            GPIO.output(13, int(request[1]))
            GPIO.output(15, int(request[2]))
except KeyboardInterrupt:
    GPIO.cleanup()

And this is what my setup looks like enter image description here enter image description here

Any ideas what I'm doing wrong? It's my first week working with my Raspberry Pi.

Idris
  • 43
  • 1
  • 3