Skip to content

Latest commit

 

History

History
64 lines (50 loc) · 2.93 KB

README.md

File metadata and controls

64 lines (50 loc) · 2.93 KB

ledPixelsPico: Setting up neopixels (WS281x addressable LEDs) on the Raspberry Pi Pico.

Adapting the ledPixels module from rpi-led-strip, to use circuitpython on the Pico

Setup:

Hardware:

  • Raspberry Pi Pico
  • Individually addressable LED strip (for example ) (20 pixels is the default)
  • Attach the LED strip to (defaults): ** Data --> GP0 ** Power --> VBUS ** Ground --> GND

Environment Setup:

  • (NOTE: setup.sh script will automatically do this setup.)
  • Connect Pico to computer using USB cable. It should show up as a USB hard drive on your computer named something like RPI-RP2 (you may need to press the BOOTSEL button as you plug it in).
  • Copy the adafruit circuitpython file (.uf2) to the RPI-RP2. It should restart and then show up as CIRCUITPY.
  • Copy the neopixel.mpy file (original can be found in the m.x-mpy zip bundle ) to CIRCUITPY.
  • Copy the ledPixelsPico.py file to CIRCUITPY.

Interpreter

  • Install an interpreter. I've found it easiest to use Thonny.
    • On Linux I've had to run a usermod command (and restart) to get Thonny to work well with the Pico:
sudo apt install thonny
usermod -a -G dialout $USER
  • Open Thonny and set the interpreter to circuitpython. If the code.py file does not automatically open, you should probably open it.

Running python programs

  • On the CIRCUITPY drive, there is a file called code.py whatever you place in that file will run. So test the LED strip with the following program, which lights up the first and last lights.
import board
import neopixel

pixels = neopixel.NeoPixel(board.GP0, 20)

pixels[0] = (20,0,0)
pixels[-1] = (0,20,0)

Learning programming with the Pico and LED strip:

  • Programming Lessons
    • Note: The examples may be aimed at the Raspberry Pi Zero, but you'll just need to change the board GPIO:
      • Change board.D18 to board.GPO on line 4 (or so).

Sensors

Examples

  • rainbow.py: Runs a rainbow pattern on repeat.
  • timer.py: Very simple timer that switches one led from green to red per second for a given number of seconds (nPix)

Output

References: