LED Matrix 8x8 Driven by MAX7219 with Arduino Uno





--------------------
LIBRARIES
--------------------

https://github.com/wayoda/LedControl

--------------------------------------------
LED Matrix Sprite Generator
--------------------------------------------

http://embed.plnkr.co/3VUsekP3jC5xwSIQDVHx/preview

Arduino Sketch



//We always have to include the library
// Based on a project posted https://github.com/wayoda/LedControl
#include "LedControl.h"

/*
 Now we need a LedControl to work with.
 // Customized for RoboJax.com on Feb 26, 2017 in Ajax, Ontario, Canada.
 ***** These pin numbers will probably not work with your hardware *****
 pin 12 is connected to the DataIn 
 pin 11 is connected to the CLK 
 pin 10 is connected to CS
 We have only a single MAX72XX.
 */
LedControl lc=LedControl(12,11,10,1);

byte Digit0[] = {B00011000,B00100100,B01000010,B01000010,B01000010,B01000010,B00100100,B00011000};
byte Digit1[] = {B00011000,B01111000,B00011000,B00011000,B00011000,B00011000,B00011000,B01111110};
byte Digit2[] = {B01111110,B00000010,B00000010,B00000010,B01111110,B01000000,B01000000,B01111110};
byte Digit3[] = {B01111110,B00000010,B00000010,B00111110,B00111110,B00000010,B00000010,B01111110};
byte Digit4[] = {B11000110,B11000110,B11000110,B11000110,B11111110,B00000110,B00000110,B00000110};
byte Digit5[] = {B11111110,B11111110,B11000000,B11000000,B11111110,B00000110,B00000110,B11111110};
byte Digit6[] = {B11111110,B11111110,B11000000,B11000000,B11111110,B11000110,B11000110,B11111110};
byte Digit7[] = {B11111110,B00000010,B00000110,B00001100,B00011000,B00110000,B01100000,B11000000};
byte Digit8[] = {B01111100,B10000010,B10000010,B01111100,B10000010,B10000010,B10000010,B01111100};
byte Digit9[] = { B01111100,B10000010,B10000010,B01111100,B00000010,B00000010,B00000010,B01111100};
byte A[] = {B00010000,B00111000,B01101100,B11000110,B11000110,B11111110,B11000110,B11000110};
byte B[] = {B00000000,B11111000,B10000100,B10000100,B11111000,B10000100,B10000100,B11111000};
byte C[] = {B00000000,B01111000,B10000100,B10000000,B10000000,B10000000,B10000100,B01111000};
byte D[] = {B11111000,B10000100,B10000010,B10000010,B10000010,B10000010,B10000100,B11111000};
byte E[] = {B11111000,B10000000,B10000000,B10000000,B11110000,B10000000,B10000000,B11111000};
byte F[] = {B11111000,B11111000,B11000000,B11110000,B11110000,B11000000,B11000000,B11000000};
byte smile[] = {B00111100,B01000010,B10100101,B10000001,B10100101,B10011001,B01000010,B00111100};

byte up[] = {B00011000,B00111100,B01111110,B11111111,B00011000,B00011000,B00011000,B00011000};
byte down[] = {B00011000,B00011000,B00011000,B00011000,B11111111,B01111110,B00111100,B00011000};
byte left[] = {B00010000,B00110000,B01110000,B11111111,B11111111,B01110000,B00110000,B00010000};
byte right[] = {B00001000,B00001100,B00001110,B11111111,B11111111,B00001110,B00001100,B00001000};
/* we always wait a bit between updates of the display */
unsigned long delaytime=1000;

void setup() {
  /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
  lc.shutdown(0,false);
  /* Set the brightness to a medium values */
  lc.setIntensity(0,1);
  /* and clear the display */
  lc.clearDisplay(0);
}




void loop() { 

   /* Letter   */

  display( up );
  display( down);
  display( left);
  display( right);

  display( Digit0);
  display( Digit1);
  display( Digit2);
  display( Digit3);
  display( Digit4);
  display( Digit5);

  display( Digit6);
  display( Digit7);
  display( Digit8);
  display( Digit9);
  
  display( A );
  display( B );
  display( C );

  display( D );
  display( E );
  display( F );
  display( smile);

 

}
void display( byte Digits[] ){
    for (int i=0; i<8; i++){
  lc.setRow(0,i,Digits[i]);

  }
   
  delay(delaytime);
  for(int i=0; i<8; i++){
      lc.setRow(0,i,0);// this is for blank
  }   
}

ความคิดเห็น