Skip to content

Instantly share code, notes, and snippets.

@scruss-elmwood
Created October 4, 2017 22:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scruss-elmwood/20bf5ec18daf8d87f2e8352c93866fd7 to your computer and use it in GitHub Desktop.
Save scruss-elmwood/20bf5ec18daf8d87f2e8352c93866fd7 to your computer and use it in GitHub Desktop.
Trinket M0 - scruss's perpetual Scottish thermometer
# Trinket M0 - scruss's perpetual Scottish thermometer
# for elmwood electronics - https://elmwood.to/
# CircuitPython 2.0.0
import board
import adafruit_dotstar as dotstar
import microcontroller
import time
# One pixel connected internally!
dot = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
######################### MAIN LOOP ##############################
message=''
colour=0x000000
while True:
temperature=microcontroller.cpu.temperature
# my own very grumpy temperature scale, in deg C
if (temperature > 23.0):
message='far too hot'
colour=0xff0000 # red
elif (temperature > 5.0):
message='just right'
colour=0x00ff00 # green
else:
message='a tad chilly'
colour=0x0000ff # blue
dot[0]=colour # display colour scale
# send message to serial port with temperature
print("Temperature: %5.1f deg C : %s" % (temperature, message))
time.sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment