Created
March 9, 2015 14:33
-
-
Save CleoQc/edc0b20947e4234dcf88 to your computer and use it in GitHub Desktop.
Control an RGB Led with the GPIO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
import time | |
GPIO.setmode(GPIO.BCM) | |
pin1 = 18 #red | |
pin2 = 23 #green | |
pin3 = 24 #blue | |
GPIO.setup(pin1,GPIO.OUT) | |
GPIO.setup(pin2,GPIO.OUT) | |
GPIO.setup(pin3,GPIO.OUT) | |
try: | |
while 1: | |
print "pin1" | |
GPIO.output(pin1,True) | |
GPIO.output(pin2,False) | |
GPIO.output(pin3,False) | |
time.sleep(1) | |
print "pin2" | |
GPIO.output(pin1,False) | |
GPIO.output(pin2,True) | |
GPIO.output(pin3,False) | |
time.sleep(1) | |
print "pin3" | |
GPIO.output(pin1,False) | |
GPIO.output(pin2,False) | |
GPIO.output(pin3,True) | |
time.sleep(1) | |
except: | |
GPIO.cleanup() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment