Updating light sensor code.
-# CircuitPlaygroundExpress_LightSensor
-# reads the on-board light sensor and graphs the brightness with NeoPixels
+# Circuit Playground Light Sensor
+# Reads the on-board light sensor and graphs the brightness with NeoPixels
import time
-
import board
import neopixel
-from analogio import AnalogIn
-from simpleio import map_range
+import analogio
+import simpleio
-pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, auto_write=0, brightness=.05)
+pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=.05, auto_write=False)
pixels.fill((0, 0, 0))
pixels.show()
-analogin = AnalogIn(board.LIGHT)
+light = analogio.AnalogIn(board.LIGHT)
while True:
# light value remapped to pixel position
- peak = map_range(analogin.value, 2000, 62000, 0, 9)
- print(analogin.value)
+ peak = simpleio.map_range(light.value, 2000, 62000, 0, 9)
+ print(light.value)
print(int(peak))
for i in range(0, 9, 1):
