import time from dht import DHT11 from machine import Pin from neopixel import NeoPixel NP_PIN = NeoPixel(Pin(15), 2) DHT_PIN = DHT11(Pin(5)) RED = 0 GREEN = 1 BLUE = 2 def init_neopixels(np_pin): """Initializes NP array.""" np_pin[0] = (128, 0, 0) np_pin[1] = (0, 0, 128) np_pin.write() def blue_to_red(np_pin, index): start = (0, 0, 56) r, g, b = np_pin[index] if b > 0: r += 4 b -= 4 np_pin[index] = (r, g, b) else: np_pin[index] = start np_pin.write() def dht_report(dht_pin): dht_pin.measure() temp = dht_pin.temperature() hum = dht_pin.humidity() result = "Temp: {}, Humidity: {}".format(temp, hum) return result def main(): init_neopixels(NP_PIN) while True: #print(dht_report(DHT_PIN)) blue_to_red(NP_PIN, 0) time.sleep_ms(100) main()