---
title: "EP-0263"
source: /docs/EP-0263
markdown: /md/EP-0263.md
---

# EP-0263

**SKU:** EP-0263 <img src="EP-0263-01-01.jpg" title="EP-0263-01-01.jpg" width="320" alt="EP-0263-01-01.jpg" />

## Description

The RGB LED Matrix Shield for Arduino NANO R4/ESP32 is a custom-designed expansion board tailored specifically for the Arduino Nano ESP32 or Arduino NANO R4 development platform. It integrates a high-density matrix of RGB LEDs, enabling developers, makers, and hobbyists to create stunning visual effects, dynamic light animations, and interactive displays with minimal wiring.

This shield adopts the compact Nano form factor, allowing it to mate seamlessly with the Arduino Nano ESP32 via standard pin headers.

Each LED on the matrix is individually addressable through a single digital control line, supporting 24-bit full-color rendering (8 bits per channel for Red, Green, and Blue) and cascading data transmission. By leveraging the powerful ESP32-S3 dual-core microcontroller (up to 240 MHz) embedded in the Arduino Nano ESP32, users can implement complex lighting algorithms, IoT-connected visual feedback systems, and real-time responsive light installations.

## Compatibility

-   **Arduino NANO ESP32：** Supports Web UI/RMT demo
-   **Arduino NANO R4:** Supports basic Neopixel demo only

<img src="EP-0263-08.jpg" title="EP-0263-08.jpg" width="800" alt="EP-0263-08.jpg" />

## Gallery

-   Product Outlook

<img src="EP-0263-01.jpg" title="EP-0263-01.jpg" width="800" alt="EP-0263-01.jpg" />

-   Product Dimension

<img src="EP-0263-02.jpg" title="EP-0263-02.jpg" width="800" alt="EP-0263-02.jpg" />

-   Power Consumption note

<img src="EP-0263-04.jpg" title="EP-0263-04.jpg" width="800" alt="EP-0263-04.jpg" />

-   Product Compatibility

<img src="EP-0263-05.jpg" title="EP-0263-05.jpg" width="800" alt="EP-0263-05.jpg" />

-   Product Demostration effect

<img src="EP-0263-07.jpg" title="EP-0263-07.jpg" width="800" alt="EP-0263-07.jpg" />

## IMPORTANT NOTE

<strong>Please note: This RGB LED matrix generates significant heat as brightness increases. To prevent burns, do not set the brightness to maximum during initial debugging. When testing, avoid staring directly at the matrix for extended periods, as this may cause eye strain or discomfort; use a semi-transparent diffuser or cover to reduce glare if necessary. For prolonged operation, additional cooling or heat-dissipation equipment is strongly recommended to avoid high-temperature contact burns.

**NOTE2:** USB power is for low-brightness testing only </strong>

## Key Features

| Feature                    | Description                                                                                                                                            |
|----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| Tailored Form Factor       | Custom-designed mechanical outline that perfectly matches the Arduino Nano ESP32 board, ensuring compact and reliable stacking.                        |
| Programmable RGB LEDs      | Programmable RGB LEDs; each pixel is independently addressable via a one-wire interface.                                                               |
| High-Density Matrix Layout | Dense grid arrangement of RGB LEDs (visible as dual matrix arrays on the shield) for smooth graphics, icons, and animation rendering.                  |
| Single-Pin Control         | Requires only one GPIO pin (D11) to drive the entire LED matrix, freeing up other I/O for sensors and peripherals.                                     |
| Rich Color Depth           | 256 brightness levels per color channel, supporting up to 16.7 million colors (24-bit RGB) per LED.                                                    |
| Expandable Interface       | Broken-out pin headers (D0-D10, D12, D13, 3V3, A0–A7, VBUS, GND, VIN, etc.) allow easy integration of additional modules, sensors, and external power. |
| Plug-and-Play USB-C        | Combined with the Nano ESP32’s USB-C connector for both power and programming, simplifying the development workflow.                                   |

## Target Audience

This product is ideal for the following user groups:

-   **Electronics Hobbyists & Makers** — Individuals who enjoy hands-on hardware projects and want to add vivid visual output to their creations without complex wiring.
-   **STEM Educators & Students** — Perfect for teaching embedded programming, digital signal protocols, and color theory in classrooms, labs, and coding workshops.
-   **IoT & Smart Device Developers** — Developers leveraging the Nano ESP32’s built-in Wi-Fi® and Bluetooth® LE to build connected lighting devices, notification panels, or ambient displays.
-   **Interactive Art & Installation Designers** — Artists and creative technologists seeking a compact, powerful, and easily programmable LED canvas for wearables, sculptures, or stage props.
-   **Prototyping Engineers** — Professionals who need rapid visual feedback systems for sensor data, status indicators, or UI mockups during product development.

## Application Scenarios

| Scenario                      | Description                                                                                                                                                     |
|-------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Ambient Lighting & Mood Lamps | Create smooth color fades, breathing effects, and music-reactive ambient lighting for desks, rooms, or vehicles.                                                |
| Wearable Electronics          | Combined with the Nano ESP32’s small footprint, the shield can be integrated into wearable badges, costumes, or portable light accessories.                     |
| IoT Notification Display      | Use Wi-Fi/Bluetooth connectivity to fetch data (weather, social media, server status) and render it as color-coded alerts or scrolling icons on the LED matrix. |
| Interactive Educational Kits  | Teach programming concepts by having students code chase lights, pixel art, or reaction games directly on the matrix.                                           |
| Miniature Billboard / Signage | Display scrolling text, simple animations, or brand logos in compact spaces such as shop windows, model dioramas, or control panels.                            |
| Audio Visualization           | Pair with a microphone module to build real-time spectrum analyzers, VU meters, or sound-reactive light shows.                                                  |
| Gaming & Entertainment        | Develop miniature retro games (e.g., Snake, Tetris) or use the matrix as a dynamic health/status bar for DIY game controllers.                                  |

## Quick Start Guide

### Hardware Setup

1.  **Mount the Shield:** Carefully align the shield’s female/male headers with the Arduino Nano ESP32’s pin headers and press them together.
2.  **Power Connection:** Connect the Nano ESP32 to your computer or a 5V USB power adapter via the USB-C port. The LED matrix will draw power from the VBUS (5V) rail.
3.  **Verify Data Pin:** Ensure the matrix data input is connected to the designated GPIO (D11).

### Software Setup

1.  **Install Arduino IDE:** Download and install the latest Arduino IDE 2.x (or 1.8.x) from <https://www.arduino.cc/en/software>.

<img src="Arduino_installation_001.png" title="Arduino_installation_001.png" width="800" alt="Arduino_installation_001.png" />
Double click the installation file and follow the instructions to install it.

1.  **Add Board Support:** In Boards Manager, add the Arduino ESP32 Boards package to support the Nano ESP32 or In Additional Boards Manager URLs, add (if not present):
    <https://espressif.github.io/arduino-esp32/package_esp32_index.json>

<img src="Arduino_installation_002.png" title="Arduino_installation_002.png" width="800" alt="Arduino_installation_002.png" />
Open Tools → Board → Boards Manager, search for "Arduino ESP32 Boards" (by Arduino) or "ESP32 by Espressif Systems", and install the latest version.

<img src="Arduino_installation_003.png" title="Arduino_installation_003.png" width="800" alt="Arduino_installation_003.png" />
<img src="Arduino_installation_004.png" title="Arduino_installation_004.png" width="800" alt="Arduino_installation_004.png" />

#### Select the Correct Board & Port

-   **Board:** Arduino Nano ESP32
-   **Port:** Select the COM port that appears when you plug in the USB-C cable.
-   **Upload Speed:** 921600 (default).

<img src="Arduino_installation_005.png" title="Arduino_installation_005.png" width="800" alt="Arduino_installation_005.png" />

#### Download and Configure the Sketch

**4.0** Download Demo code Sketch from: *\[ <https://github.com/geeekpi/RGB-LED-Matrix-Shield-for-Arduino-NANO-R4-ESP32> \]*

Open the provided firmware sketch. You must edit the following three sections before uploading:

**4.1 WiFi Credentials:**

``` cpp
static const char* ssid     = "YOUR_SSID_HERE";      // <-- Change this
static const char* password = "YOUR_PASSWORD_HERE";    // <-- Change this
```

Note: The ESP32 will operate in Station (STA) mode. Ensure your 2.4 GHz network uses WPA2 or WPA3. The serial monitor will display connection progress and the assigned IP address.

**4.2 Verify Libraries**

This firmware uses only the ESP32 Arduino Core built-in libraries:

-   **\<WiFi.h\>** Library version: WiFi==2.0.0
-   **\<WebServer.h\>** : WiFiWebServer==1.10.1
-   **\<esp32-hal-rmt.h\>**: ESP32==2.0.0

No third-party ZIP libraries (e.g., Adafruit NeoPixel or FastLED) are required because the code drives the WS2812 protocol directly via the ESP32 RMT peripheral.

**4.3 Compile & Upload**

-   Click the Verify (checkmark) button to ensure the code compiles without errors.
-   Click Upload and wait for the "Done uploading" message.
-   Open Tools → Serial Monitor (115200 baud).
-   Press the RST button on the Nano ESP32 once if you do not see output.

**4.4 Obtain the Device IP**

In the Serial Monitor, look for the following lines:

<img src="Arduino_installation_006.png" title="Arduino_installation_006.png" width="800" alt="Arduino_installation_006.png" />
Record this IP address—you will need it to access the control panel.

**4.5 Access the Web Control Panel**

On any device connected to the same WiFi network, open a modern web browser.

<strong> **NOTE：Important Network Requirements for Web-Based Control**

Please note that the Arduino NANO ESP32 only supports 2.4 GHz Wi-Fi networks. It cannot connect to 5GHz networks or dual-band networks broadcasting exclusively on 5GHz.

If you intend to debug or control the LED lighting effects via a web interface, your computer, smartphone, or tablet must be connected to the same local area network (LAN) as the Arduino NANO ESP32. </strong>

This means:

-   Both your client device and the NANO ESP32 must be on the same 2.4 GHz Wi-Fi network.
-   They must reside within the same subnet (e.g., 192.168.1.x) so that the web browser can reach the IP address assigned to the board.
-   The NANO ESP32 cannot be accessed over the Internet or from a different network (such as a mobile data connection or a guest network) unless additional port forwarding or a remote relay server is configured separately.
-   Before uploading your sketch, ensure your router has a dedicated 2.4 GHz SSID available, or verify that your dual-band router is set to allow 2.4 GHz connections. Failure to do so will prevent the board from joining the network and make the web-based lighting controller unreachable.

If the device has been connected to 2.4GHz network, you can access it via browser from your computer or mobile phone’s browser.

Navigate to: [`http://192.168.x.xxx`](http://192.168.x.xxx)

The embedded NanoESP32 RGB LED Control interface will load instantly. It requires no internet access and works on desktop, tablet, or mobile browsers.

## Using the Web Interface

<img src="Webcontrol25.png" title="Webcontrol25.png" width="800" alt="Webcontrol25.png" />
The onboard UI provides real-time control over:

| Control              | Function                                                                                                        |
|----------------------|-----------------------------------------------------------------------------------------------------------------|
| Power (On/Off)       | Instantly blanks or restores the LED matrix.                                                                    |
| Mode                 | Choose from Heartbeat, Solid Red, Rainbow, Rainbow OP, Chase, Breathe, Theater, Larson, Twinkle, Smiley, Blink. |
| Brightness           | 0–255 global dimming applied before RMT output.                                                                 |
| Heart Rate （speed） | 1–10 multiplier affecting animation step rates.                                                                 |

All UI actions call the REST API asynchronously; the ESP32 responds immediately and updates the LED frame on the next update_effect() cycle.

## Developer Appendix

### REST API Reference (for Developers Only)

**NOTE:** The REST API reference sections in the demo code of this project are intended solely for developer debugging purposes. We do not provide any technical support for these sections. Your understanding is appreciated.

You can also control the device programmatically via HTTP GET:

| Endpoint                     | Example                    | Description                                                                                                                                              |
|------------------------------|----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `/api/state`                 | `/api/state`               | Returns JSON with power, effect, brightness, speed, IP, and LED count.                                                                                   |
| `/api/power?on=1`            | `/api/power?on=1`          | Turn matrix on (`on=1`) or off (`on=0`).                                                                                                                 |
| `/api/brightness?v=128`      | `/api/brightness?v=128`    | Set global brightness (`0–255`).                                                                                                                         |
| `/api/speed?v=5`             | `/api/speed?v=5`           | Set animation speed (`1–10`).                                                                                                                            |
| `/api/effect?name=heartbeat` | `/api/effect?name=rainbow` | Switch effect. Valid names: `solid`, `rainbow`, `rainbow_op`, `chase`, `breathe`, `theater`, `larson`, `twinkle`, `heartbeat`, `smiley`, `smiley_blink`. |

#### `/api/state` Response Format

\<

``` json
{
  "power": true,
  "effect": "heartbeat",
  "brightness": 128,
  "speed": 5,
  "num_leds": 104,
  "ip": "192.168.x.xxx"
}
```

#### Supported Effect Names

| Name           | Description                                                                                                                                                       |
|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `solid`        | Solid red color across all LEDs.                                                                                                                                  |
| `rainbow`      | Rainbow spectrum animation flowing across all LEDs.                                                                                                               |
| `rainbow_op`   | Rainbow background with hollow "OP" letters displayed on the matrix. Letters are rendered in rainbow stroke with black interior, and the hue continuously shifts. |
| `chase`        | Single white LED chasing across the matrix.                                                                                                                       |
| `breathe`      | Red breathing/pulsing effect with sine wave modulation.                                                                                                           |
| `theater`      | Theater chase effect with orange LEDs.                                                                                                                            |
| `larson`       | Larson scanner (Cylon/KITT) effect with red trail decay.                                                                                                          |
| `twinkle`      | Random white twinkling LEDs with fade decay.                                                                                                                      |
| `heartbeat`    | Red heart shape with realistic "lub-dub" double-peak heartbeat pulse animation.                                                                                   |
| `smiley`       | Static yellow smiley face with red eyes.                                                                                                                          |
| `smiley_blink` | Yellow smiley face with blinking red eyes animation (eyes close to yellow every \~7% of cycle).                                                                   |

#### Example Usage with curl

``` bash

## Turn on the matrix

curl "http://192.168.x.xxx/api/power?on=1"

## Set effect to heartbeat (default)

curl "http://192.168.x.xxx/api/effect?name=heartbeat"

## Set effect to rainbow

curl "http://192.168.x.xxx/api/effect?name=rainbow"

## Set effect to rainbow OP letters

curl "http://192.168.x.xxx/api/effect?name=rainbow_op"

## Set effect to smiley

curl "http://192.168.x.xxx/api/effect?name=smiley"

## Set brightness to 50 (low)

curl "http://192.168.x.xxx/api/brightness?v=50"

## Set speed to 8 (fast)

curl "http://192.168.x.xxx/api/speed?v=8"

## Turn off the matrix

curl "http://192.168.x.xxx/api/power?on=0"
```

#### Important Notes

-   The Arduino Nano ESP32 only supports **2.4 GHz Wi-Fi networks**. It cannot connect to 5 GHz networks.
-   Your client device (computer, smartphone, or tablet) must be connected to the **same local network** as the Arduino Nano ESP32 to access the REST API.
-   All API endpoints respond with `application/json` content type.
-   Brightness value range: `0–255` (0 = off, 255 = maximum brightness).
-   Speed value range: `1–10` (1 = slowest, 10 = fastest).
-   The default effect on boot is **Heartbeat** (`heartbeat`).
-   The default brightness on boot is **128**.
-   The default speed on boot is **5**.
-   There is **no `off` effect** in this version. To turn off all LEDs, use `/api/power?on=0` instead.

<img src="Rest_api_state.png" title="Rest_api_state.png" width="800" alt="Rest_api_state.png" />

### Effect Engine Details

The firmware runs an internal 50 FPS render loop (update_effect()). Each effect is computed in RAM and then pushed to the RGB LED chain via the RMT peripheral:

-   **Rainbow:** Full HSV spectrum mapped linearly across the LED array; hue rotates continuously.
-   **Chase:** A single white pixel travels along the strip; speed controls step size.
-   **Breathe:** Sinusoidal amplitude modulation (10%–100%) applied to the selected solid color.
-   **Theater:** Classic 3-phase chasing amber pattern (255, 80, 0).
-   **Larson:** A red "Cylon/KITT" scanner with a decaying tail that bounces between ends.
-   **Twinkle:** Per-frame decay (200/255) plus stochastic white sparkles seeded by a lightweight xorshift32 PRNG.

## Important Notes & Troubleshooting

-   **Power Budget:** At full white (255,255,255) and g_brightness = 255, each RGB LED can draw \~60 mA. A 104-LED matrix may require \> 6 A at peak. The USB-C port typically supplies 500 mA–1 A. For reliable high-brightness operation, power the matrix from an external 5V supply and connect the supply GND to the ESP32 GND.
-   **RMT Tick Accuracy:** The firmware sets rmtSetTick(rmtTx, 100) for 100 ns resolution. Do not alter T0H/T0L/T1H/T1L timing values unless you are switching to a different LED chipset.
-   **Reset Pulse:** After each frame, the code waits 300 µs to satisfy the RGB LED \> 50 µs reset requirement. This is conservative and ensures latch reliability.
-   **Theater Offset Jitter:** At extreme g_speed values (\> 8), the Theater effect may skip phases due to modulo arithmetic.
-   **Data Flow Direction & First LED Location**

The WS281x RGB LEDs on this matrix are wired in a serial (daisy-chain) configuration. Because data propagates sequentially from one LED to the next, it is critical that the signal enters at the correct starting point and follows the exact path indicated on the PCB.

-   **First LED (D1):** The starting point is clearly marked as D1 at the top-left corner of the board (see the silkscreen label). Your microcontroller's data output must be connected to this input (Default is D11 Pin).
-   **Data Flow Direction:** Follow the white arrows printed on the PCB backside. The signal travels from D1 through each subsequent LED in the order defined by these arrows.
-   **Serpentine (Snake) Routing:** The matrix uses a zigzag layout. Data flows down one column, then loops back up the next, continuing in this alternating pattern across the entire array.
-   **Important Wiring Note:** WS281x LEDs are unidirectional. If the data line is connected to the wrong end or the flow is reversed, the LEDs will not light up.

## Arduino Nano R4 - RGB LED Matrix Shield Guide

If using Arduino Nano R4, please use the following method.

## Overview

This sketch creates a smooth, animated rainbow cycle across a 104-pixel RGB LED matrix. The effect runs continuously in a loop, with adjustable speed and brightness.

| Component  | Specification                                                                                                   |
|------------|-----------------------------------------------------------------------------------------------------------------|
| Board      | Arduino NANO R4 Board                                                                                           |
| Shield     | RGB LED Matrix Shield (104 RGB LEDs)                                                                            |
| Connection | The shield stacks directly onto the NANO R4 headers. Ensure the data pin aligns with D11.                       |
| Power      | USB power is sufficient for low brightness. For full white at high brightness, use an external 5V power supply. |

## Library Installation

You must install the Adafruit NeoPixel library before uploading the code.

Using the Arduino IDE Library Manager:

1.  Open the Arduino IDE (version 1.8.x or 2.x).

<img src="Arduino_installation_009.png" title="Arduino_installation_009.png" width="800" alt="Arduino_installation_009.png" />

1.  Go to Sketch → Include Library → Manage Libraries...
2.  In the search bar, type: **Adafruit NeoPixel**
    Tested version: 1.15.4
3.  Find the library by Adafruit and click Install.

<img src="Arduino_installation_010.png" title="Arduino_installation_010.png" width="800" alt="Arduino_installation_010.png" />

1.  Wait for the installation to complete, then close the window.

## Uploading the Code

1.  Connect your Arduino NANO R4 to your computer via USB-C.
2.  Open the Arduino IDE.
3.  Copy and paste the provided sketch into a new file.
4.  Select the correct board:
    -   Tools → Board → Arduino Nano ESP32 or Arduino Nano R4 (depending on your IDE version and core installation).
5.  Select the correct port:
    -   Tools → Port → Select the COM port (Windows) or /dev/tty... (macOS/Linux).
6.  Click the Upload button (right arrow icon).
7.  Once the upload is complete, the LED matrix should immediately begin displaying the rainbow animation.

<img src="Arduino_installation_011.png" title="Arduino_installation_011.png" width="800" alt="Arduino_installation_011.png" />

## Code Explanation

### Global Definitions

``` cpp
#define PIN 11
#define NUMPIXELS 104
#define BRIGHTNESS 30
```

-   **PIN 11:** The digital pin sending data to the LED matrix.
-   **NUMPIXELS 104:** Total number of individually addressable LEDs on your shield.
-   **BRIGHTNESS 30:** Master brightness limit (0–255). 30 is dim but power-efficient and eye-friendly.

### Object Initialization

``` cpp
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
```

-   Creates a pixels object representing the LED strip/matrix.
-   **NEO_GRB:** Color order (Green-Red-Blue). Required for tested with WS2812B LEDs.
-   **NEO_KHZ800:** Data signaling speed (800 kHz), standard for WS2812B.

### About setup() section

``` cpp
void setup() {
  pixels.begin();
  pixels.show();
}
```

-   **begin():** Prepares the data pin for output.
-   **show():** Pushes the current color data to the hardware. Since no colors are set yet, this turns all LEDs off initially.

### About loop() section

``` cpp
void loop() {
  rainbowCycle(20);
}
```

-   The main execution loop. It repeatedly calls rainbowCycle() with a wait value of 20 milliseconds between frames.

### About rainbowCycle(uint8_t wait) section

``` cpp
for (j = 0; j < 256; j++) {
  for (i = 0; i < pixels.numPixels(); i++) {
    uint32_t color = Wheel((i * 256 / pixels.numPixels() + j) & 255);
    pixels.setPixelColor(i, dimColor(color, BRIGHTNESS));
  }
  pixels.show();
  delay(wait);
}
```

-   **j loop:** Cycles through 256 color-wheel positions, creating the animation over time.
-   **i loop:** Iterates through every pixel on the matrix.
-   **Wheel(...):** Calculates a base rainbow color based on the pixel’s position and the current animation frame.
-   **dimColor(...):** Scales the calculated color down to the defined BRIGHTNESS.
-   **pixels.show():** Updates the entire matrix with the new frame.
-   **delay(wait):** Controls animation speed. Lower = faster; higher = slower.

### About Wheel(byte WheelPos) section

``` cpp
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if (WheelPos < 85) {
    return pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  }
  if (WheelPos < 170) {
    WheelPos -= 85;
    return pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  WheelPos -= 170;
  return pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
```

-   Generates a standard RGB rainbow gradient by transitioning smoothly through:
    1.  Red → Yellow (adds Green)
    2.  Yellow → Green (removes Red)
    3.  Green → Blue (removes Green, adds Blue)
-   The 255 - WheelPos reversal inverts the direction of the color flow.

### About dimColor(uint32_t color, uint8_t brightness) section

``` cpp
uint32_t dimColor(uint32_t color, uint8_t brightness) {
  uint8_t r = (color >> 16) & 0xFF;
  uint8_t g = (color >> 8) & 0xFF;
  uint8_t b = color & 0xFF;
  r = r * brightness / 255;
  g = g * brightness / 255;
  b = b * brightness / 255;
  return pixels.Color(r, g, b);
}
```

-   Extracts the Red, Green, and Blue components from a 32-bit color value.
-   Scales each channel proportionally by the brightness factor.
-   Recombines them into a new, dimmer color.

## How to Modify the Effect by yourself?

Here are several safe ways to customize the sketch without breaking the core logic.

### A. Change the Animation Speed

In loop(), adjust the argument passed to rainbowCycle():

``` cpp
rainbowCycle(5);   // Very fast
rainbowCycle(50);  // Slow and smooth
rainbowCycle(100); // Very slow
```

### B. Adjust Brightness

Change the \#define BRIGHTNESS value at the top of the file:

``` cpp
#define BRIGHTNESS 10   // Dim (good for dark rooms)
#define BRIGHTNESS 100  // Medium
#define BRIGHTNESS 255  // Maximum brightness (high power consumption)
```

**Warning:** At 255, all 104 LEDs drawing full white could exceed 500mA. Ensure your USB port or power supply can handle the current.

### C. Reverse the Rainbow Direction

Remove or comment out the reversal line in Wheel():

``` cpp
// WheelPos = 255 - WheelPos; // Comment out this line
```

This makes the colors cycle in the opposite direction.

### D. Create a Static Rainbow (No Animation)

If you want a fixed rainbow pattern that does not move, modify rainbowCycle() to remove the outer j loop and use a fixed offset:

``` cpp
void staticRainbow() {
  for (int i = 0; i < pixels.numPixels(); i++) {
    uint32_t color = Wheel((i * 256 / pixels.numPixels()) & 255);
    pixels.setPixelColor(i, dimColor(color, BRIGHTNESS));
  }
  pixels.show();
}
```

Then call staticRainbow(); inside loop() without any delay, or add a long delay to hold the image.

### E. Add a Button Trigger (Intermediate)

Using another pin, you can trigger the rainbow only when a button is pressed:

``` cpp
#define BUTTON_PIN 2

void setup() {
  pixels.begin();
  pixels.show();
  pinMode(BUTTON_PIN, INPUT_PULLUP);
}

void loop() {
  if (digitalRead(BUTTON_PIN) == LOW) {
    rainbowCycle(20);
  } else {
    pixels.clear();
    pixels.show();
  }
}
```

## Troubleshooting

| Problem              | Solution                                                                                                            |
|----------------------|---------------------------------------------------------------------------------------------------------------------|
| No LEDs light up     | Check that the shield is firmly seated on D11. Verify USB/power connection. Ensure NUMPIXELS matches your hardware. |
| Wrong colors         | Try changing NEO_GRB to NEO_RGB or NEO_BGR in the constructor.                                                      |
| Nano R4 not detected | Install the Arduino Nano R4 board package via Boards Manager if you have not already done so.                       |

## Summary

This sketch provides a plug-and-play rainbow animation for your Arduino NANO R4 and 104-pixel RGB Matrix Shield. By installing the Adafruit Neopixel library and uploading the code, you get an immediate visual result. You can then experiment with speed, brightness, and color logic to create your own custom light patterns.

## Package Includes

-   1 × RGB LED Matrix Shield for Arduino NANO R4/ESP32
-   1 × Quick Start Reference Manual

*(Arduino Nano ESP32 mainboard sold separately.)*