Build it step by step
0 of 8 doneInstall the board package
Arduino UNO R4 Boards in the Boards Manager.
Select the board
Arduino UNO R4 WiFi.
Wire the button
D2 to GND.
Upload the sketch
A happy face appears.
Wait three seconds
The face blinks.
Press the button
Sad, then surprised, then happy.
Design a new face
Edit the hash patterns.
Add a frame
Make an animation with two or three frames.
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
| From | To | Why |
|---|---|---|
| Button leg 1 | Uno R4 pin D2 | Face change input |
| Button leg 2 | Uno R4 GND | Pressed pulls D2 low |
| USB-C cable | Uno R4 USB-C port | Power and upload |
| Built-in LED matrix | Inside the board, no wiring | 12 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.
| Check | Expected |
|---|---|
| Power on | Happy face on the matrix |
| After three seconds | A quick blink |
| First button press | Sad face |
| Second button press | Surprised face |
| Third button press | Back 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 →
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.
