##############################################################
# 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
import random
import time
from neopixel import NeoPixel
pin = Pin(2, Pin.OUT) # set GPIO 2 to output to drive NeoPixels
np = NeoPixel(pin, 18) # create NeoPixel driver on GPIO 2 for 18 pixels
while True:
red = random.randint(0, 256)
green = random.randint(0, 256)
blue = random.randint(0, 256)
np.fill((red, green, blue))
np.write()
time.sleep(1)