code.py
 1  # SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  import time
 6  from adafruit_circuitplayground.express import cpx
 7  import simpleio
 8  
 9  cpx.pixels.auto_write = False
10  cpx.pixels.brightness = 0.3
11  
12  while True:
13      # light value remapped to pixel position
14      peak = simpleio.map_range(cpx.light, 0, 320, 0, 10)
15      print(cpx.light)
16      print(int(peak))
17  
18      for i in range(0, 10, 1):
19          if i <= peak:
20              cpx.pixels[i] = (0, 255, 255)
21          else:
22              cpx.pixels[i] = (0, 0, 0)
23      cpx.pixels.show()
24      time.sleep(0.05)