NeoPXL8 now also works on boards with the RP2040 and RP2350 microcontrollers, such as the Raspberry Pi Pico, Raspberry Pi Pico 2, or Adafruit Feather RP2040.
By and large it functions the same, with just some minor changes to the rules…
- Requires the Earle Philhower RP2040 board support in Arduino, not Mbed RP2040. If you don’t already have this installed, the steps are documented in this guide.
- The pin list passed to the constructor…rather than Arduino pin numbers (silkscreened on the top of some boards), this requires GPIO bit numbers, which aren’t always the same. On the Feather RP2040 and ItsyBitsy RP2040, GPIO bit numbers are silkscreened on the bottom of the board. On Raspberry Pi Pico, the numbers are the same, and Pico guidelines such as avoiding GP15 apply.
- The 8 GPIO bits must be contiguous, e.g. GP00 through GP07. They do not need to be aligned to any particular boundary though, just contiguous. 1–8, 3–10 and so forth.
- It’s more efficient with RAM, requiring about 2X as much as the regular single-strand NeoPixel library, vs. 4X RAM on SAMD chips. And the RP2040 already has lots of RAM!
Hardware
Since RP2040 and RP2350 are 3.3 Volt devices, you’ll want to convert logic levels to the NeoPixel supply voltage (5V typ.).
For most boards, our NeoPXL8 Friend does this nicely. It’s explained further on the “NeoPXL8 Breakout Board” page of this guide.
However…if you’re using a Feather RP2040, and if you’re comfortable with some fine soldering, our NeoPXL8 FeatherWing M4 (not the M0 version) can be adapted. Then you have a tidy package with less wiring!
If the work looks troublesome for your current soldering skill, no worries, you can still wire up a NeoPXL8 Friend. And to reiterate, this modification specifically requires the M4 version of the FeatherWing.
Locate the n0 selector pads on the FeatherWing and use an X-Acto knife or small file to cut the trace between n0 and SCK.
Solder a short piece of insulated solid-core wire between the now-isolated n0 surface pad and the last through-hole via in this row.
If you’ll be using the RJ-45 connections for pixels, make sure this wire clears the mounting hole in the board.
This step may take a few tries and some desoldering wick. Those pads are designed for solder bridges, but now we want to keep n0 isolated.
Remember when installing the headers that these components are on the bottom of the FeatherWing.
All other selectable pins — n1 through n3 — should be left in their default configurations.
Software
The strandtest Arduino sketch includes some processor-specific notes. You’ll need to set up the pins[] list and call the constructor like so:
int8_t pins[8] = { 6, 7, 9, 8, 13, 12, 11, 10 }; // GP## indices! Adafruit_NeoPXL8 leds(NUM_LED, pins, NEO_GRB);
On the Feather RP2040, those correspond to digital pins 4, 5, 9, 6, 13, 12, 11, and 10 on the top silkscreen. This is the only 8-pin list that works between NeoPXL8 and the Feather RP2040.
For other hardware, there’s usually more flexibility…just provide a list of eight contiguous GPIO bits. They don’t need to be in-order, merely contiguous.
And that’s it! Most existing NeoPXL8 sketches (which are very similar to regular NeoPixel sketches) will then carry right over. Some may need small changes…and that’s not always because of NeoPXL8, it’s sometimes unrelated hardware differences.
For example, the Ooze Master 3000 project can be adapted with just a couple code changes…
First, the pin list around line 23 should be modified…either the list given above (if using Feather RP2040 + NeoPXL8 FeatherWing M4), or a list of GPIO bits if using a different board with NeoPXL8 Friend.
Second, change the randomSeed() call (around line 68) to reference only pin A0, not A0 + A5. The RP2040 only has four analog inputs. Or you can just delete the line. The code is just using unconnected analog inputs to randomize things on startup, but it’s not vital.
randomSeed(analogRead(A0));
The code should then compile successfully for RP2040 and RP2350 boards.
Text editor powered by tinymce.