from machine import Pin, ADC
from time import sleep
from neopixel import NeoPixel
from random import randint
NUM_PIXELS = 16
def convert(x, in_min, in_max, out_min, out_max):
return (x - in_min) * (out_max - out_min) // (in_max - in_min) + out_min
potR = ADC(Pin(12, Pin.IN))
potG = ADC(Pin(13, Pin.IN))
potB = ADC(Pin(14, Pin.IN))
btn = Pin(15, Pin.IN, Pin.PULL_UP)
pixels1 = NeoPixel(Pin(22), NUM_PIXELS)
pixels2 = NeoPixel(Pin(23), NUM_PIXELS)
while True:
r = randint(0,255)
g = randint(0,255)
b = randint(0,255)
pixels1.fill((r,g,b))
pixels1.write()
while btn.value():
R = convert(potR.read(), 0, 4095, 0, 255)
G = convert(potG.read(), 0, 4095, 0, 255)
B = convert(potB.read(), 0, 4095, 0, 255)
pixels2.fill((R,G,B))
pixels2.write()
print(f"R: {r}\t{R}")
print(f"G: {g}\t{G}")
print(f"B: {b}\t{B}\n")
sleep(2)