Projects / Matrix face animator

Matrix face animator

Beginner2 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. UNO

    Install the board package

    Arduino UNO R4 Boards in the Boards Manager.

  2. UNO

    Select the board

    Arduino UNO R4 WiFi.

  3. UNO

    Wire the button

    D2 to GND.

  4. UNO

    Upload the sketch

    A happy face appears.

  5. UNO

    Wait three seconds

    The face blinks.

  6. UNO

    Press the button

    Sad, then surprised, then happy.

  7. UNO

    Design a new face

    Edit the hash patterns.

  8. UNO

    Add a frame

    Make an animation with two or three frames.

In short

How do you build a matrix face animator?

The built-in 12 by 8 LED matrix on an Uno R4 WiFi shows animated faces that change with a button, with no extra display parts. You need Arduino Uno R4 WiFi, Tactile push button 6 mm, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points. It takes 8 steps and about 120 minutes.

Level
Beginner
Time
About 120 min
Parts
4

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Button leg 1Uno R4 pin D2Face change input
Button leg 2Uno R4 GNDPressed pulls D2 low
USB-C cableUno R4 USB-C portPower and upload
Built-in LED matrixInside the board, no wiring12 columns by 8 rows, driven by the Arduino_LED_Matrix library

Code

The Uno R4 WiFi has a small grid of 96 LEDs, twelve across and eight down, built into the board itself, so you can show pictures with no wiring at all. The library draws a frame from an array of eight rows and twelve columns, where one means lit and zero means off. Writing each face as eight text lines of twelve characters, with a hash for a lit LED, makes the pictures easy to read and edit, and a short function turns the text into the frame the library expects. A button on a digital pin steps through three faces, and the happy face blinks every three seconds by swapping to a second frame for a moment, which is the basic idea behind every animation: show frames in a sequence with a timer. The sketch uses millis for the timing instead of delay, so the button always responds immediately. Draw your own faces by changing the hash patterns. Install the Arduino UNO R4 board package first, as the matrix library comes with it. The board runs from 5 volts, and USB power is enough.

Runs on a virtual Arduino Uno R4 WiFi in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include "Arduino_LED_Matrix.h"

ArduinoLEDMatrix matrix;
const int BTN = 2;

// Each face is 8 rows of 12 characters. A hash is a lit LED.
const char *HAPPY[8] = {
  "............",
  "..##....##..",
  "..##....##..",
  "............",
  "..#......#..",
  "...######...",
  "............",
  "............"
};
const char *BLINK[8] = {
  "............",
  "............",
  "..##....##..",
  "............",
  "..#......#..",
  "...######...",
  "............",
  "............"
};
const char *SAD[8] = {
  "............",
  "..##....##..",
  "..##....##..",
  "............",
  "....####....",
  "...#....#...",
  "............",
  "............"
};
const char *SURPRISED[8] = {
  "............",
  ".###....###.",
  ".#.#....#.#.",
  ".###....###.",
  "....####....",
  "....#..#....",
  "....####....",
  "............"
};

const char **FACES[4] = {HAPPY, SAD, SURPRISED, HAPPY};
int faceIndex = 0;
bool wasPressed = false;
unsigned long lastPress = 0, lastBlink = 0;
bool blinking = false;

void draw(const char **face) {
  uint8_t frame[8][12];
  for (int r = 0; r < 8; r++)
    for (int c = 0; c < 12; c++)
      frame[r][c] = (face[r][c] == '#') ? 1 : 0;
  matrix.renderBitmap(frame, 8, 12);
}

void setup() {
  pinMode(BTN, INPUT_PULLUP);
  matrix.begin();
  draw(HAPPY);
}

void loop() {
  bool pressed = (digitalRead(BTN) == LOW);
  if (pressed && !wasPressed && millis() - lastPress > 40) {
    lastPress = millis();
    faceIndex = (faceIndex + 1) % 3;           // happy, sad, surprised
    draw(FACES[faceIndex]);
  }
  wasPressed = pressed;

  if (faceIndex == 0) {                        // only the happy face blinks
    if (!blinking && millis() - lastBlink > 3000) {
      blinking = true; lastBlink = millis();
      draw(BLINK);
    } else if (blinking && millis() - lastBlink > 150) {
      blinking = false; lastBlink = millis();
      draw(HAPPY);
    }
  }
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Power onHappy face on the matrix
After three secondsA quick blink
First button pressSad face
Second button pressSurprised face
Third button pressBack to happy

If it does not work

Nothing on the matrix

Check the board selection and that the upload finished.

Library not found

Install the UNO R4 Boards package.

Faces upside down

Rotate the board or reverse the row order.

Button double-steps

Increase the 40 millisecond lockout.

Blinks too fast

Raise the 3000 millisecond interval.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the matrix face animator?

Arduino Uno R4 WiFi, Tactile push button 6 mm, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points.

How long does the matrix face animator take to build?

About 120 minutes for a beginner maker, in 8 steps.

How do I know the matrix face animator works?

Power on: Happy face on the matrix. After three seconds: A quick blink. First button press: Sad face.

Nothing on the matrix: what should I check?

Check the board selection and that the upload finished.

Library not found: what should I check?

Install the UNO R4 Boards package.

Faces upside down: what should I check?

Rotate the board or reverse the row order.

Button double-steps: what should I check?

Increase the 40 millisecond lockout.