Projects / Animated eight-by-eight faces

Animated eight-by-eight faces

Beginner1.5 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. NANO9.4 mA

    Wire the driver

    VCC to 5V, GND to GND, SDA to A4, SCL to A5.

  2. NANO

    Wire the button

    D2 to GND.

  3. NANO9.4 mA

    Install the libraries

    Adafruit LED Backpack and Adafruit GFX.

  4. NANO

    Upload the sketch

    A smiling face appears.

  5. NANO

    Watch the animation

    The faces change about every 400 ms.

  6. NANO

    Press the button

    Cycle through slow, medium and fast.

  7. NANO

    Fix the orientation

    Change setRotation if the picture is turned.

  8. NANO

    Draw your own

    Add a new frame of eight bytes.

In short

How do you build an animated eight-by-eight faces?

An LED matrix driver shows small faces and shapes that change on a timer, with a button to change the speed. You need Arduino Nano, HT16K33 LED matrix driver, 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 90 minutes.

Level
Beginner
Time
About 90 min
Parts
5

Parts list

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

Wiring

FromToWhy
Matrix driver VCCNano 5VPower
Matrix driver GNDNano GNDCommon ground
Matrix driver SDANano A4I2C data
Matrix driver SCLNano A5I2C clock
ButtonNano D2 to GNDChanges the animation speed

Code

The HT16K33 chip scans an LED matrix by itself and talks to the board over I2C, so only two data wires are needed and the Nano is free to do other things. Each picture is stored as eight bytes, one per row, where every bit is one LED. The sketch keeps four frames in program memory, a smile, a neutral face, a frown and a heart, and a timer based on millis moves to the next one without blocking the loop. The button steps through three speeds, and you will notice the faces blend into one moving picture at the fastest setting. To make your own frame, draw an eight by eight grid on paper, write a one for each lit pixel, and turn each row into a binary number. Install the Adafruit LED Backpack and Adafruit GFX libraries from the Library Manager. Boards made by other makers can be wired in a different pixel order, so if the picture looks mirrored or turned, change the setRotation value from 0 to 1, 2 or 3 until it looks right. Keep the brightness low, because a matrix with many pixels lit draws noticeable current from USB.

Runs on a virtual Arduino Nano 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 <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_LEDBackpack.h>

Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
const int BTN = 2;

// Each frame is eight rows, left pixel is the highest bit. PROGMEM keeps them out of RAM.
static const uint8_t PROGMEM FRAMES[4][8] = {
  {B00111100, B01000010, B10100101, B10000001, B10100101, B10011001, B01000010, B00111100},  // smile
  {B00111100, B01000010, B10100101, B10000001, B10111101, B10000001, B01000010, B00111100},  // neutral
  {B00111100, B01000010, B10100101, B10000001, B10011001, B10100101, B01000010, B00111100},  // frown
  {B01100110, B11111111, B11111111, B11111111, B01111110, B00111100, B00011000, B00000000}   // heart
};
const unsigned int SPEEDS[3] = {1000, 400, 150};   // milliseconds per frame
int speedIx = 1, frame = 0;
unsigned long lastChange = 0;
bool wasDown = false;

void show(int f) {
  matrix.clear();
  matrix.drawBitmap(0, 0, FRAMES[f], 8, 8, LED_ON);
  matrix.writeDisplay();
}

void setup() {
  pinMode(BTN, INPUT_PULLUP);
  matrix.begin(0x70);          // the usual address; scan if your board differs
  matrix.setBrightness(4);     // 0 to 15, keep it low on USB power
  matrix.setRotation(0);       // try 1, 2 or 3 if the picture is turned
  show(0);
}

void loop() {
  bool down = (digitalRead(BTN) == LOW);
  if (down && !wasDown) { speedIx = (speedIx + 1) % 3; delay(30); }
  wasDown = down;

  if (millis() - lastChange >= SPEEDS[speedIx]) {
    lastChange = millis();
    frame = (frame + 1) % 4;
    show(frame);
  }
}

Test checklist

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

CheckExpected
Power onFirst frame shows within a second
Four framesSmile, neutral, frown, heart repeat in order
Button pressSpeed changes each time
Rotation changedPicture turns to match your matrix
Brightness 4Comfortable and no warm board

If it does not work

Nothing lights

Check VCC, GND and that SDA and SCL are on A4 and A5.

Display stays blank after upload

Scan the I2C address, it may not be 0x70.

Picture is mirrored

Try the other setRotation values.

Compile error about the library

Install both Adafruit libraries.

Button changes speed twice

Keep the 30 ms delay after a press.

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

Ask Lark AI

Common questions

What parts do I need for the animated eight-by-eight faces?

Arduino Nano, HT16K33 LED matrix driver, Tactile push button 6 mm, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points.

How long does the animated eight-by-eight faces take to build?

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

How do I know the animated eight-by-eight faces works?

Power on: First frame shows within a second. Four frames: Smile, neutral, frown, heart repeat in order. Button press: Speed changes each time.

Nothing lights: what should I check?

Check VCC, GND and that SDA and SCL are on A4 and A5.

Display stays blank after upload: what should I check?

Scan the I2C address, it may not be 0x70.

Picture is mirrored: what should I check?

Try the other setRotation values.

Compile error about the library: what should I check?

Install both Adafruit libraries.