mdraber
Published © GPL3+

Controlling 8x8 Dot Matrix with Max7219 and Arduino

So far I was controling those matrixes with multiplexing. In this video I would use MAX7219 chip to do it

BeginnerFull instructions provided35,311
Controlling 8x8 Dot Matrix with Max7219 and Arduino

Things used in this project

Story

Read more

Schematics

Schematics

Code

MAX7219 - using Led Control library to display two 8x8 bitmaps

Arduino
//Mario's Ideas
//MAX7219 - using Led Control library to display 8x8 bitmap
#include <LedControl.h>

int DIN = 11;
int CS = 7;
int CLK = 13;
LedControl lc=LedControl(DIN, CLK, CS,0);

int Cat[8] ={B10001000,B11111000,B10101000,B01110001,B00100001,B01111001,B01111101,B10111110 };
byte Apple [8]={B00011000,B00001000,B01110110,B11111111,B11111111,B11111111,B01111010,B00110100};

void setup() {
  lc.shutdown(0,false);
  lc.setIntensity(0,0);
  lc.clearDisplay(0);
}
  
void loop(){
  for(int i=0;i<8;i++) lc.setRow(0,i,Apple[i]);
  delay(5000);
  lc.clearDisplay(0);
  for(int i=0;i<8;i++) lc.setRow(0,i,Cat[i]);
  delay(5000);
  lc.clearDisplay(0);
}

MAX7219 - using SPI library to display 8x8 bitmap

Arduino
// Mario's Ideas
//MAX7219 - using SPI library to display 8x8 bitmap
#include <SPI.h>
#define CS 7

// MAX7219 Control registers

#define DECODE_MODE 9 
#define INTENSITY 0x0A
#define SCAN_LIMIT 0x0B 
#define SHUTDOWN 0x0C
#define DISPLAY_TEST 0x0F

byte Apple [8]={B00011000,B00001000,B01110110,B11111111,B11111111,B11111111,B01111010,B00110100};

void SendData(uint8_t address, uint8_t value) {  
  digitalWrite(CS, LOW);   
  SPI.transfer(address);      // Send address.
  SPI.transfer(value);        // Send the value.
  digitalWrite(CS, HIGH); // Finish transfer.
}
void setup() {
  pinMode(CS, OUTPUT);  
  SPI.setBitOrder(MSBFIRST);   // Most significant bit first 
  SPI.begin();                 // Start SPI
  SendData(DISPLAY_TEST, 0x01);       // Run test - All LED segments lit.
  delay(1000);
  SendData(DISPLAY_TEST, 0x00);           // Finish test mode.
  SendData(DECODE_MODE, 0x00);            // Disable BCD mode. 
  SendData(INTENSITY, 0x0e);              // Use lowest intensity. 
  SendData(SCAN_LIMIT, 0x0f);             // Scan all digits.
  SendData(SHUTDOWN, 0x01);               // Turn on chip.
}
void loop()  {

for (int i=1;i<9;i++) SendData(i, Apple[i-1]);

}

MAX7219 - using Led Control library to display all leds one by one

Arduino
//Mario's Ideas
//MAX7219 - using Led Control library to display all leds one by one
#include <LedControl.h>

int DIN = 11;
int CS = 7;
int CLK = 13;

LedControl lc=LedControl(DIN, CLK, CS,0);



void setup() {

  lc.shutdown(0,false);
  lc.setIntensity(0,0);
  lc.clearDisplay(0);
}

void loop() {
  for(int j=0;j<8;j++){
     for(int i=0;i<8;i++){
       lc.setLed(0,j,i,true);
       delay(100);
       lc.setLed(0,j,i,false);
     }
  }
}

MAX7219 - using Led Control library to scroll the sample text

Arduino
// Mario's Ideas
//MAX7219 - using Led Control library to scroll the sample text
#include <LedControl.h>

int DIN = 11;
int CS = 7;
int CLK = 13;
LedControl lc=LedControl(DIN, CLK, CS,0);

int position=0;

int Marios_ideas [8] [54] ={
  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
  {0,1,0,0,0,1,0,0,1,1,0,0,1,1,1,0,0,0,0,0,1,1,0,1,0,1,1,0,0,0,0,0,0,1,1,1,0,0,1,1,1,0,0,1,1,0,0,0,1,1,0,0,0,0},
  {0,1,1,0,1,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0},
  {0,1,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,0,0,0},
  {0,1,0,0,0,1,0,1,1,1,1,0,1,1,1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,0,0,1,0,1,0,0,1,0,1,1,1,0,1,1,1,1,0,0,1,1,0,0,0,0},
  {0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0},
  {0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,1,0,0,1,0,0, 1,0,0,0,1,0,1,1,1,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0},
  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0}
  };


void setup() {

   lc.shutdown(0,false);
   lc.setIntensity(0,0);
   lc.clearDisplay(0);
}

void loop() {
  for (int j=0;j<8;j++){
    for (int i=0;i<8;i++){
    lc.setLed(0,i,j,Marios_ideas[j][(i+position)-abs((i+position)/54)*54]);
    }
  }
  delay(20);
  position=position+1;
}  

Credits

mdraber

mdraber

49 projects • 67 followers

Comments