Last active
March 17, 2018 14:30
-
-
Save mattintosh4/5d173cbb016a35c808d2757cf7e5666a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/python | |
| import time | |
| import RPi.GPIO as GPIO | |
| import spidev | |
| import psutil | |
| SEG = [ | |
| 0b00111111 # 0 | |
| , 0b00000110 # 1 | |
| , 0b01011011 # 2 | |
| , 0b01001111 # 3 | |
| , 0b01100110 # 4 | |
| , 0b01101101 # 5 | |
| , 0b01111101 # 6 | |
| , 0b00100111 # 7 | |
| , 0b01111111 # 8 | |
| , 0b01101111 # 9 | |
| ] | |
| spi = spidev.SpiDev() | |
| spi.open(0, 0) | |
| spi.max_speed_hz = 10000 | |
| try: | |
| while True: | |
| users = len(psutil.users()) | |
| spi.xfer([SEG[users]]) | |
| time.sleep(0.4) | |
| except: | |
| spi.close() | |
| GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment