Merge pull request #978 from adafruit/TheKitty-patch-113
Add code for the guide "Twinkly Earwarmer Headband"
This commit is contained in:
commit
1e8fe9b8aa
2 changed files with 45 additions and 0 deletions
11
GemmaM0_Headband/README.md
Normal file
11
GemmaM0_Headband/README.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
## Twinkly Earwarmer Headband Tutorial code
|
||||
|
||||
Code to accompany the tutorial Twinkly Earwarmer Headband (using an Adafruit Gemma M0) by Kathy Ceceri
|
||||
|
||||
CircuitPython Code by Anne Barela
|
||||
|
||||
See this guide at https://learn.adafruit.com/TwinklyEarwarmer/overview
|
||||
|
||||
MIT License, please attribute and include this file.
|
||||
|
||||
Adafruit expends resources providing open source materials, please support their work by buying products at https://www.adafruit.com
|
||||
34
GemmaM0_Headband/code.py
Normal file
34
GemmaM0_Headband/code.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# Gemma M0 Onchip Temperature Sensor
|
||||
# Project by Kathy Ceceri
|
||||
# CircuitPython by Anne Barela
|
||||
# Adafruit Industries, 2019
|
||||
|
||||
import time
|
||||
import board
|
||||
import microcontroller
|
||||
import neopixel
|
||||
import adafruit_dotstar
|
||||
|
||||
ROOM_TEMP = 65.0 # Set this to the temp to change from blue to red (F)
|
||||
|
||||
# Set up NeoPixel strand
|
||||
pixels = neopixel.NeoPixel(board.D1, # NeoPixels on pin D1
|
||||
4, # Number of Pixels
|
||||
brightness=0.2) # Change from 0.0 to 1.0
|
||||
|
||||
# For the Gemma M0 onboard DotStar LED
|
||||
dotstar = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
|
||||
|
||||
def deg_f(deg_c): # Convert Celcius to Fahrenheit
|
||||
return(deg_c * 9 / 5) + 32.0
|
||||
|
||||
while True:
|
||||
temp = deg_f(microcontroller.cpu.temperature)
|
||||
if temp > ROOM_TEMP:
|
||||
pixels.fill((255, 0, 0)) # (255,0,0) is red
|
||||
dotstar.fill((255, 0, 0)) # Set to red
|
||||
else:
|
||||
pixels.fill((0, 0, 255)) # (0,0,255) is blue
|
||||
dotstar.fill((0, 0, 255)) # Set to blue
|
||||
|
||||
time.sleep(1.0) # Wait 1 second
|
||||
Loading…
Reference in a new issue