Created
September 22, 2013 09:57
-
-
Save tam203/6658528 to your computer and use it in GitHub Desktop.
WOW LEDS
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 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