Skip to content

Instantly share code, notes, and snippets.

@bennuttall
Last active April 4, 2018 15:13
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 bennuttall/fd684f2d24e5c67a306410da54a39362 to your computer and use it in GitHub Desktop.
Save bennuttall/fd684f2d24e5c67a306410da54a39362 to your computer and use it in GitHub Desktop.
Demo using sense_hat and sense_emu together to control the Sense HAT's physical LEDs using the emulator's temperature sensor slider
from sense_hat import SenseHat
from sense_emu import SenseHat as SenseEmu
hat = SenseHat()
emu = SenseEmu()
while True:
temp = emu.temperature
r = int(min(max(0, temp), 100) / 100 * 255)
print('{:3d}'.format(r), end='\r', flush=True)
hat.clear(r, 0, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment