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  # Set these based on your ambient temperature for best results!
13  minimum_temp = 24
14  maximum_temp = 30
15  
16  while True:
17      # temperature value remapped to pixel position
18      peak = simpleio.map_range(cpx.temperature, minimum_temp, maximum_temp, 0, 10)
19      print(cpx.temperature)
20      print(int(peak))
21  
22      for i in range(0, 10, 1):
23          if i <= peak:
24              cpx.pixels[i] = (0, 255, 255)
25          else:
26              cpx.pixels[i] = (0, 0, 0)
27      cpx.pixels.show()
28      time.sleep(0.05)