Need to add a simple diagnostic display to a Pico project? Or perhaps you want a quick and easy NeoPixel light show? Let's see what we can do!
Build Instructions
- Break off three header pins
- Solder the pins on the NeoPixel Stick: GND, DIN, 5VDC
- Attach the Pico to the PiCowBell plate
- The USB connector goes over the QTPY connector on the plate
- Plug in the NeoPixel Stick
- 5VDC connects to IO15
- DIN connects to IO14
- GND connects to the nearby GND pin
Install CircuitPython
Follow the instructions on CircuitPython.org -- any 9.0 build will do.
Use Circup to install the neopixel library:
circup install neopixel
NeoPixel Lightshow
Save this code to the Pi Pico as "code.py":
"simple light show"
import board
import digitalio
import neopixel
import random
import time# set GP15 to Output, High
bvcc = digitalio.DigitalInOut(board.GP15)
bvcc.direction = digitalio.Direction.OUTPUT
bvcc.value = 1 # provide 3.3v# eight pixels on GP14
pixel = neopixel.NeoPixel(board.GP14, 8, brightness=0.025)
pixel.fill((0,255,0))
def anycolor():
"returns a random RGB color"
return random.choice([
(255,255,0),
(0,255,0),
(32,32,255),
(240,64,0)
])while True:
pixel[random.choice(range(8))]=anycolor()
time.sleep(0.1)
How It Works
The Pi Pico has convenient ground pins in many places. We use pin 18 for GND. The NeoPixel Stick DIN is connected to pin 19 (GP14), and we use pin 20 (GP15) to power the NeoPixel Stick.
The code sets up GP15 to Output and High. It sets up GP14 do drive the NeoPixels. Then in a loop it updates the pixel colors.