Skip to content

Instantly share code, notes, and snippets.

@tam203
Created September 22, 2013 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tam203/6658528 to your computer and use it in GitHub Desktop.
Save tam203/6658528 to your computer and use it in GitHub Desktop.
WOW LEDS
import urllib
import time
import RPi.GPIO as GPIO
GPIO.cleanup()
GPIO.setmode(GPIO.BCM)
GPIO.setup(7,GPIO.OUT)
pinNumbers = [4,17,22,23,24]
for i in pinNumbers:
GPIO.setup(i,GPIO.OUT)
number = 0
while True:
try:
r = urllib2.urlopen("http://intelij.local/fashionclimate/php/emissions/latest_rate/eguser/")
e = int(r.read())
print e;
number = e
except Exception as e:
raise e
print "error"
pass
ledsOn = (e/20)+1
if ledsOn>5:
ledsOn=5
if ledsOn<0:
ledsOn=1
for i in pinNumbers:
GPIO.output(i,GPIO.LOW)
for i in range(0,ledsOn):
GPIO.output(pinNumbers[i],GPIO.HIGH)
time.sleep(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment