Updated and added new code

This commit is contained in:
Kattni Rembor 2018-05-24 17:35:41 -04:00
parent b6c39cd1f2
commit 4f00b479c8
4 changed files with 32 additions and 3 deletions

View file

@ -6,7 +6,7 @@ cpx.pixels.auto_write = False
cpx.pixels.brightness = 0.3
while True:
# light value remaped to pixel position
# light value remapped to pixel position
peak = simpleio.map_range(cpx.light, 0, 320, 0, 10)
print(cpx.light)
print(int(peak))

View file

@ -1,6 +1,4 @@
import time
from adafruit_circuitplayground.express import cpx
while True:
print("Slide switch:", cpx.switch)
time.sleep(0.5)

View file

@ -0,0 +1,7 @@
from adafruit_circuitplayground.express import cpx
while True:
if cpx.switch:
cpx.red_led = True
else:
cpx.red_led = False

View file

@ -0,0 +1,24 @@
import time
from adafruit_circuitplayground.express import cpx
import simpleio
cpx.pixels.auto_write = False
cpx.pixels.brightness = 0.3
# Set these based on your ambient temperature for best results!
minimum_temp = 24
maximum_temp = 30
while True:
# temperature value remapped to pixel position
peak = simpleio.map_range(cpx.temperature, minimum_temp, maximum_temp, 0, 10)
print(cpx.temperature)
print(int(peak))
for i in range(0, 10, 1):
if i <= peak:
cpx.pixels[i] = (0, 255, 255)
else:
cpx.pixels[i] = (0, 0, 0)
cpx.pixels.show()
time.sleep(0.05)