dot matrix max7219 arduino

8×8 Dot Matrix MAX7219 Arduino Tutorial

Posted on

8×8 Dot Matrix MAX7219 Arduino Tutorial – This article is prioritized for you beginners in learning Arduino. The 8×8 dot matrix is ​​included in a project that is popular today. With this 8×8 dot matrix we can make a larger matrix. Usually this dot matrix is ​​used to show public information such as digital clocks, directions, announcements, toll road information, running posts and so on. To be able to use dot matrix, please use the following schematic. Note, this article uses the MAX7219 driver as a multiplexing driver. For font generator, please visit this website.

dot matrix max7219 arduino

Progam:

#include "LedControl.h"

const int quantityDot = 1;
const int csPin  = 10;
const int clkPin = 11;
const int dataPin = 12;
int delaytime = 5;

const byte font[] = {
  0x1c, 0x22, 0x22, 0x3e, 0x22, 0x22, 0x22, 0x00, // A
  0x3c, 0x22, 0x22, 0x3e, 0x22, 0x22, 0x3c, 0x00, // B
  0x1c, 0x22, 0x20, 0x20, 0x20, 0x22, 0x1c, 0x00, // C
  0x3c, 0x22, 0x22, 0x22, 0x22, 0x22, 0x3c, 0x00, // D
  0x3e, 0x20, 0x20, 0x3e, 0x20, 0x20, 0x3e, 0x00, // E
  0x3e, 0x20, 0x20, 0x3e, 0x20, 0x20, 0x20, 0x00, // F
  0x1c, 0x22, 0x20, 0x2e, 0x22, 0x22, 0x1c, 0x00, // G
  0x22, 0x22, 0x22, 0x3e, 0x22, 0x22, 0x22, 0x00, // H
  0x1c, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1c, 0x00, // I
  0x1c, 0x08, 0x08, 0x08, 0x08, 0x28, 0x10, 0x00, // J
  0x22, 0x24, 0x28, 0x30, 0x28, 0x24, 0x22, 0x00, // K
  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3e, 0x00, // L
  0x22, 0x36, 0x2a, 0x22, 0x22, 0x22, 0x22, 0x00, // M
  0x22, 0x22, 0x32, 0x2a, 0x26, 0x22, 0x22, 0x00, // N
  0x1c, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1c, 0x00, // O
  0x3c, 0x22, 0x22, 0x3c, 0x20, 0x20, 0x20, 0x00, // P
  0x1c, 0x22, 0x22, 0x22, 0x2a, 0x24, 0x1a, 0x00, // Q
  0x3c, 0x22, 0x22, 0x3c, 0x28, 0x24, 0x22, 0x00, // R
  0x1c, 0x22, 0x20, 0x1c, 0x02, 0x22, 0x1c, 0x00, // S
  0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, // T
  0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1c, 0x00, // U
  0x22, 0x22, 0x22, 0x22, 0x22, 0x14, 0x08, 0x00, // V
  0x22, 0x22, 0x22, 0x2a, 0x2a, 0x36, 0x22, 0x00, // W
  0x22, 0x22, 0x14, 0x08, 0x14, 0x22, 0x22, 0x00, // X
  0x22, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08, 0x00, // Y
  0x3e, 0x02, 0x04, 0x08, 0x10, 0x20, 0x3e, 0x00, // Z
};

LedControl lc = LedControl(dataPin, clkPin, csPin, quantityDot);

void setup()
{
  lc.shutdown(0, false);
  lc.setIntensity(0, 8); // set brightnees 0-15
  lc.clearDisplay(0);
}

void loop()
{
  single();
  delay(1000);
  showFont();
}

void showFont() {
  for (char character = 'A'; character <= 'Z'; character++)
  {
    int pos = (character - 'A') * 8;
    for (int row = 0; row < 8; row++)
    {
      byte val = font [row + pos];
      for (int bit = 7; bit >= 0; bit--)
      {
        byte col = 7 - bit;
        if (bitRead(val, bit) == 1)
          lc.setLed(0, row, col, true);
        else
          lc.setLed(0, row, col, false);
      }
    }
    delay(1000);
  }
}

void single() {
  for (int row = 0; row < 8; row++) {
    for (int col = 0; col < 8; col++) {
      delay(delaytime);
      lc.setLed(0, row, col, true);
      delay(delaytime);
    }
  }
}

Video:

Read other articles  How to use 20×4 LCD I2C with Arduino

Other News in Home Hambo Elektronik.

Leave a Reply

Your email address will not be published. Required fields are marked *