##############################################################
# Neopixel WS2812 LED Interface #
##############################################################
#
# Neopixel WS2812 LED interface with Raspberry Pi Pico / W / 2 / w2 (Hardware & Simulation)
#
# Check out the link for Code explanation and Hardware details
# Link:
# http://tech.arunkumarn.in/blogs/raspberry-pi-pico/
#
#
from machine import Pin, ADC
import time
from neopixel import NeoPixel
pin = Pin(2, Pin.OUT) # set GPIO 2 to output to drive NeoPixels
np = NeoPixel(pin, 16) # create NeoPixel driver on GPIO 2 for 16 pixels
red_control = ADC(28)
green_control = ADC(27)
blue_control = ADC(26)
# def cap_value(data):
# return int((data/65535)*255)
# Caping the color value to max 255
cap_value = lambda x: int((x/65535)*255)
while True:
red = red_control.read_u16()
green = green_control.read_u16()
blue = blue_control.read_u16()
red = cap_value(red)
green = cap_value(green)
blue = cap_value(blue)
# print(red, green, blue)
np.fill((red, green, blue))
np.write()
time.sleep_ms(100)
RED
GREEN
BLUE
WS2812