Created
October 4, 2017 22:09
-
-
Save scruss-elmwood/20bf5ec18daf8d87f2e8352c93866fd7 to your computer and use it in GitHub Desktop.
Trinket M0 - scruss's perpetual Scottish thermometer
This file contains 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
# 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