"""ADC slider demo — drag the sliders that appear under the editor. Two simulated ADCs: * pin 34 — sets the base hue of a rainbow * pin 35 — sets overall brightness The strip lights up while the script runs; the values update live (no need to restart the script when you move the slider). """ import time from machine import ADC, Pin from neopixel import NeoPixel NUM_LEDS = 16 strip = NeoPixel(Pin(5, Pin.OUT), NUM_LEDS) hue_pot = ADC(Pin(34)) bri_pot = ADC(Pin(35)) def hsv_to_rgb(h, s, v): h = h - int(h) i = int(h * 6) f = h * 6 - i p = v * (1 - s) q = v * (1 - f * s) t = v * (1 - (1 - f) * s) if i == 0: r, g, b = v, t, p elif i == 1: r, g, b = q, v, p elif i == 2: r, g, b = p, v, t elif i == 3: r, g, b = p, q, v elif i == 4: r, g, b = t, p, v else: r, g, b = v, p, q return int(r * 255), int(g * 255), int(b * 255) print("Move the ADC sliders below the editor while this runs.") while True: base_hue = hue_pot.read_u16() / 65535 brightness = bri_pot.read_u16() / 65535 for i in range(NUM_LEDS): h = (base_hue + i / NUM_LEDS) % 1.0 strip[i] = hsv_to_rgb(h, 1.0, brightness) strip.write() time.sleep(0.04)