Skip to content

Instantly share code, notes, and snippets.

@rdmarsh
Created April 3, 2015 13:57
Show Gist options
  • Select an option

  • Save rdmarsh/76a11d335fa07d5509b4 to your computer and use it in GitHub Desktop.

Select an option

Save rdmarsh/76a11d335fa07d5509b4 to your computer and use it in GitHub Desktop.
Silly program to light up LEDs on raspberrypi piface depending on system load
#!/usr/bin/python
#silly program to light up LEDs on raspberrypi piface depending on system load
#basically multiplys load by x10, rounds, and lights up that many leds
from time import sleep
import pifacedigitalio
import sys
DELAY = 1.0 # seconds
MAXLED = 8
MULTIPLIER = 10
if __name__ == "__main__":
pifacedigital = pifacedigitalio.PiFaceDigital()
while True:
file = open('/proc/loadavg', 'r')
line = file.readline()
load = line.split( )
omin = float(load[0])
omin = round(omin * MULTIPLIER,0)
omin = int(omin)
if omin > MAXLED:
omin = MAXLED
for offled in range (omin,MAXLED):
pifacedigital.leds[offled].turn_off()
for onled in range(omin):
pifacedigital.leds[onled].turn_on()
sleep(DELAY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment