Skip to content

Commit c8472b6

Browse files
authored
Add files via upload
1 parent 5ebf009 commit c8472b6

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Gemma/GemmaM0_Headband/code.py

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

0 commit comments

Comments
 (0)