breadboard
docs

Example project · Displays

Uno R4 · LED matrix heart

The official Arduino_LED_Matrix library scans a heart through the real 12×8 matrix pins. Edit the bitmap in Code to change the pattern.

The Uno R4 · LED matrix heart circuit as rendered by the simulator

How it works

The UNO R4 WiFi has a 12 × 8 red LED matrix on the board and no display controller for it. The RA4M1 lights the LEDs itself by multiplexing a group of pins, turning on a small set at a time fast enough that the eye sees a steady picture. The official Arduino_LED_Matrix library does this from a timer interrupt, so the sketch only has to describe the picture.

The heart is an 8 × 12 array of 0s and 1s, one array row per matrix row. matrix.begin() starts the library's timer, and renderBitmap(heart, 8, 12) copies the array into the frame that the interrupt scans. loop() is empty: once the frame is set, the timer interrupt keeps refreshing the LEDs with no help from the sketch.

What to watch

The heart appears on the matrix shortly after boot and stays there. Compare it with the array in Code: each 1 is a lit LED, and the first row of the array is all zeros, so the top row stays dark.

What's on the bench

  • Arduino Uno R4

The code

This Arduino C++ sketch lives in Code; sign in and press Compile & upload to build real firmware for the emulated board.

#include <Arduino_LED_Matrix.h>

ArduinoLEDMatrix matrix;

uint8_t heart[8][12] = {
  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0},
  {0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0},
  {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
  {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},
  {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0},
  {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0},
  {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0},
};

void setup() {
  matrix.begin();
  matrix.renderBitmap(heart, 8, 12);
}

void loop() {}

Firmware licence

Notice: this firmware uses the LGPL-licensed Arduino core library

arduino-unor4wifi-matrix-heart.bin is statically linked with ArduinoCore-renesas 1.6.0, in Breadboard's port of its UNO R4 WiFi variant to Renesas FSP 5.3.0. Parts of that core are licensed under the GNU Lesser General Public License, version 2.1 or (at your option) any later version ("the Library"). Breadboard distributes this firmware under terms that permit you to modify the work for your own use and to reverse engineer it for debugging such modifications.

Try this

  • Edit the heart array, for example to draw your initial, then sign in and press Compile & upload. The new pattern appears after the upload.
  • Make the heart beat: in loop(), render the heart, wait 500 ms, render an array of zeros and wait again.
  • Open the scrolling text example next. It uses ArduinoGraphics on the same matrix to draw text instead of a fixed bitmap.

Related projects