Skip to content

Instantly share code, notes, and snippets.

@bennuttall
Last active December 7, 2015 00:03
Show Gist options
  • Select an option

  • Save bennuttall/8aa874e8f70ca5ff9a17 to your computer and use it in GitHub Desktop.

Select an option

Save bennuttall/8aa874e8f70ca5ff9a17 to your computer and use it in GitHub Desktop.
Number of astronauts in space
from gpiozero import LED
import requests
from time import sleep
pins = [9, 22, 8, 18, 7, 17, 25, 23, 24] # choose your own pin numbers - these are the SnowPi pins
leds = [LED(p) for p in pins]
url = "http://api.open-notify.org/astros.json"
while True:
r = requests.get(url)
j = r.json()
n = j['number']
for i, led in enumerate(leds):
if n > i:
led.on()
else:
led.off()
sleep(60) # update every minute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment