Skip to content

Commit 1e8fe9b

Browse files
authored
Merge pull request adafruit#978 from adafruit/TheKitty-patch-113
Add code for the guide "Twinkly Earwarmer Headband"
2 parents 82dde52 + 97a50fd commit 1e8fe9b

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

GemmaM0_Headband/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Twinkly Earwarmer Headband Tutorial code
2+
3+
Code to accompany the tutorial Twinkly Earwarmer Headband (using an Adafruit Gemma M0) by Kathy Ceceri
4+
5+
CircuitPython Code by Anne Barela
6+
7+
See this guide at https://learn.adafruit.com/TwinklyEarwarmer/overview
8+
9+
MIT License, please attribute and include this file.
10+
11+
Adafruit expends resources providing open source materials, please support their work by buying products at https://www.adafruit.com

GemmaM0_Headband/code.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Gemma M0 Onchip Temperature Sensor
2+
# Project by Kathy Ceceri
3+
# CircuitPython by Anne Barela
4+
# Adafruit Industries, 2019
5+
6+
import time
7+
import board
8+
import microcontroller
9+
import neopixel
10+
import adafruit_dotstar
11+
12+
ROOM_TEMP = 65.0 # Set this to the temp to change from blue to red (F)
13+
14+
# Set up NeoPixel strand
15+
pixels = neopixel.NeoPixel(board.D1, # NeoPixels on pin D1
16+
4, # Number of Pixels
17+
brightness=0.2) # Change from 0.0 to 1.0
18+
19+
# For the Gemma M0 onboard DotStar LED
20+
dotstar = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
21+
22+
def deg_f(deg_c): # Convert Celcius to Fahrenheit
23+
return(deg_c * 9 / 5) + 32.0
24+
25+
while True:
26+
temp = deg_f(microcontroller.cpu.temperature)
27+
if temp > ROOM_TEMP:
28+
pixels.fill((255, 0, 0)) # (255,0,0) is red
29+
dotstar.fill((255, 0, 0)) # Set to red
30+
else:
31+
pixels.fill((0, 0, 255)) # (0,0,255) is blue
32+
dotstar.fill((0, 0, 255)) # Set to blue
33+
34+
time.sleep(1.0) # Wait 1 second

0 commit comments

Comments
 (0)