Updated and added new code
This commit is contained in:
parent
b6c39cd1f2
commit
4f00b479c8
4 changed files with 32 additions and 3 deletions
|
|
@ -6,7 +6,7 @@ cpx.pixels.auto_write = False
|
||||||
cpx.pixels.brightness = 0.3
|
cpx.pixels.brightness = 0.3
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
# light value remaped to pixel position
|
# light value remapped to pixel position
|
||||||
peak = simpleio.map_range(cpx.light, 0, 320, 0, 10)
|
peak = simpleio.map_range(cpx.light, 0, 320, 0, 10)
|
||||||
print(cpx.light)
|
print(cpx.light)
|
||||||
print(int(peak))
|
print(int(peak))
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
import time
|
|
||||||
from adafruit_circuitplayground.express import cpx
|
from adafruit_circuitplayground.express import cpx
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
print("Slide switch:", cpx.switch)
|
print("Slide switch:", cpx.switch)
|
||||||
time.sleep(0.5)
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
from adafruit_circuitplayground.express import cpx
|
||||||
|
|
||||||
|
while True:
|
||||||
|
if cpx.switch:
|
||||||
|
cpx.red_led = True
|
||||||
|
else:
|
||||||
|
cpx.red_led = False
|
||||||
24
CircuitPython_Made_Easy_On_CPX/cpx_temperature_neopixels.py
Normal file
24
CircuitPython_Made_Easy_On_CPX/cpx_temperature_neopixels.py
Normal 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)
|
||||||
Loading…
Reference in a new issue