Skip to content

Commit fa077fc

Browse files
authored
Add code
1 parent 415576a commit fa077fc

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

GemmaM0_Headband/code.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
# Set up NeoPixel strand
13+
pixels = neopixel.NeoPixel(board.D1, # NeoPixels on pin D1
14+
4, # Number of Pixels
15+
brightness=0.2, # Change from 0.0 to 1.0
16+
auto_write=True) # Write strand immediately
17+
18+
# For the Gemma M0 onboard DotStar LED
19+
dotstar = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
20+
21+
def deg_f(deg_c): # Convert Celcius to Fahrenheit
22+
return(deg_c * 9 / 5) + 32.0
23+
24+
while True:
25+
temp = deg_f(microcontroller.cpu.temperature)
26+
if temp > 65.0:
27+
pixels.fill((255, 0, 0)) # (255,0,0) is red
28+
dotstar.fill((255, 0, 0)) # Set to red
29+
else:
30+
pixels.fill((0, 0, 255)) # (0,0,255) is blue
31+
dotstar.fill((0, 0, 255)) # Set to blue
32+
33+
time.sleep(1.0) # Wait 1 second

0 commit comments

Comments
 (0)