101 lines
5.8 KiB
Markdown
101 lines
5.8 KiB
Markdown
# RP2040 MIDI Tracker
|
|
|
|
A simple MIDI step sequencer using a Raspberry Pi Pico (or Pico W), an OLED display, a rotary encoder, and an 8x8 NeoPixel matrix.
|
|
|
|
## Software Requirements
|
|
|
|
* **Board Core**: This project uses the **Raspberry Pi Pico/RP2040** core by **Earle F. Philhower, III**.
|
|
1. Add this URL to your Additional Boards Manager URLs in Preferences:
|
|
`https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json`
|
|
2. Go to **Tools > Board > Boards Manager**, search for **"pico"**, and install **Raspberry Pi Pico/RP2040**.
|
|
3. Select **Raspberry Pi Pico** (or **Pico W**) from the board menu.
|
|
* **Libraries**: Install via Library Manager:
|
|
* `Adafruit GFX Library`, `Adafruit SSD1306`, `Adafruit NeoPixel`
|
|
|
|
## Connections & Wiring
|
|
|
|
Properly wiring the components is crucial, especially for power.
|
|
|
|
### Power
|
|
|
|
The project is best powered in two parts:
|
|
1. **Raspberry Pi Pico W**: Power the Pico via its Micro-USB port from a computer or a USB wall adapter.
|
|
2. **NeoPixel 8x8 Matrix**: This component is power-hungry and **requires a separate, external 5V power supply**. A power supply capable of delivering at least 2A is recommended.
|
|
|
|
> **WARNING**: Do NOT power the NeoPixel matrix from the Pico's 3.3V or VBUS pins. VBUS is connected directly to the USB port, which is typically limited to 500mA. The matrix can draw over 2A, which could overload and damage your host computer's USB port.
|
|
|
|
### Component Wiring
|
|
|
|
Make sure to establish a **common ground** by connecting the ground from your external 5V power supply to one of the GND pins on the Pico.
|
|
|
|
| Component | Pico Pin | Description |
|
|
| :--- | :--- | :--- |
|
|
| **SSD1306 OLED** | | |
|
|
| VCC | 3V3 (OUT) (Pin 36) | 3.3V Power |
|
|
| GND | GND (Pin 38) | Ground |
|
|
| SDA | GP4 (Pin 6) | I2C Data |
|
|
| SCL | GP5 (Pin 7) | I2C Clock |
|
|
| **Rotary Encoder** | | |
|
|
| + (VCC) | 3V3 (OUT) (Pin 36) | 3.3V Power |
|
|
| GND | GND (Pin 33) | Ground |
|
|
| CLK | GP12 (Pin 16) | Encoder Clock |
|
|
| DT | GP13 (Pin 17) | Encoder Data |
|
|
| SW | GP14 (Pin 19) | Encoder Switch |
|
|
| **WS2812B 8x8 Matrix**| | |
|
|
| DIN (Data In) | GP2 (Pin 4) | NeoPixel Data |
|
|
| 5V / VCC | External 5V Supply `+` | **External 5V Power** |
|
|
| GND | External 5V Supply `-` | **External Power Ground** |
|
|
| | GND (Pin 18) | **Common Ground with Pico** |
|
|
| **MIDI DIN (Serial)** | | |
|
|
| TX (MIDI OUT) | GP0 (Pin 1) | To DIN Pin 5 (via 220Ω) |
|
|
|
|
**MIDI Hardware Note**:
|
|
* **MIDI OUT**: Connect **GP0** to DIN Pin 5 via a 220Ω resistor. Connect DIN Pin 4 to 3.3V (3V3) via a 220Ω resistor. Connect DIN Pin 2 to GND.
|
|
|
|
Once everything is wired up, you can upload the code and your tracker should be ready to go!
|
|
|
|
## Making it Portable
|
|
|
|
To run this project without being tethered to a computer, you'll need a portable power source that can supply both the Pico and the power-hungry NeoPixel matrix.
|
|
|
|
### Option 1: Using a USB Power Bank (Easiest)
|
|
|
|
This is the simplest and safest method.
|
|
|
|
* **What you'll need:** A standard USB power bank with at least two outputs, capable of supplying a total of 2.5A or more.
|
|
* **Pico Power:** Connect a standard Micro-USB cable from one of the power bank's outputs to the Pico's USB port.
|
|
* **Matrix Power:** Use a second USB cable to power the NeoPixel matrix. You will likely need to cut the end of a USB cable and connect the 5V (usually red) and GND (usually black) wires to the matrix's power input.
|
|
* **Common Ground:** The common ground is handled automatically through the USB connections to the same power bank. However, it is still best practice to run a dedicated wire from the matrix's GND to one of the Pico's GND pins.
|
|
|
|
### Option 2: LiPo Battery with a 5V Booster (More Compact)
|
|
|
|
For a more integrated build that can fit inside an enclosure, you can use a Lithium Polymer (LiPo) battery and a voltage-boosting board.
|
|
|
|
* **What you'll need:**
|
|
* A single-cell (3.7V) LiPo battery.
|
|
* A 5V booster board, such as the Adafruit PowerBoost 1000C. These boards can charge the LiPo battery and provide a stable 5V output.
|
|
|
|
> **LIPO BATTERY WARNING**: LiPo batteries are powerful but require careful handling.
|
|
> * **Never** use a LiPo battery without a dedicated protection circuit, which prevents over-charge, over-discharge, and short-circuits. Boards like the PowerBoost series have this built-in.
|
|
> * Do not puncture, bend, or short-circuit a LiPo battery.
|
|
> * Always charge them with a proper LiPo charger.
|
|
|
|
* **Wiring:**
|
|
1. Connect the **LiPo battery** to the battery input terminals on the **PowerBoost board**.
|
|
2. Connect the **PowerBoost's 5V output** to the **NeoPixel Matrix's 5V/VCC input**.
|
|
3. Connect the **PowerBoost's 5V output** to the **Pico's VBUS pin (Pin 40)**. This will power the Pico.
|
|
4. Connect the **PowerBoost's GND** to **both** the **NeoPixel Matrix's GND** and one of the **Pico's GND pins**. This creates the essential common ground.
|
|
|
|
## Usage
|
|
|
|
* **Navigation**: Rotate the encoder to move between steps.
|
|
* **Edit Mode**: Short press the encoder button to toggle Edit Mode. Rotate to change the note.
|
|
* **Playback**: Long press the encoder button (> 0.6s) to Start/Stop playback.
|
|
* **MIDI**: The device sends MIDI notes via the Hardware Serial (DIN) port on GP0.
|
|
|
|
## Troubleshooting
|
|
- NeoPixel LEDs randomly lighting full bright white? Try a different pin. E.g. pin 16 has some noise that messes with the precise timing of the NeoPixel.
|
|
- MIDI signal not accepted by a device? Check that you're using 3.3V and not 5V. Some devices accept it, others don't. MIDI uses 3V3.
|
|
- Device freezing and restarting? Watchdog detected a deadlock and restarted the system. Check for `midi.lock()` & `midi.unlock()` called *exactly once* one after another. Calling lock twice causes a deadlock.
|
|
- NeoPixel not lighting up? Connect it to an external power source strong enough to drive 3A. Don't power it directly from the Pico.
|