Components and supplies
Arduino Nano R3
MAXREFDES99# MAX7219 Display Driver Shield
Project description
Code
MAX7219 - using Led Control library to display all leds one by one
arduino
1//Mario's Ideas 2//MAX7219 - using Led Control library to display all leds one by one 3#include <LedControl.h> 4 5int DIN = 11; 6int CS = 7; 7int CLK = 13; 8 9LedControl lc=LedControl(DIN, CLK, CS,0); 10 11 12 13void setup() { 14 15 lc.shutdown(0,false); 16 lc.setIntensity(0,0); 17 lc.clearDisplay(0); 18} 19 20void loop() { 21 for(int j=0;j<8;j++){ 22 for(int i=0;i<8;i++){ 23 lc.setLed(0,j,i,true); 24 delay(100); 25 lc.setLed(0,j,i,false); 26 } 27 } 28}
MAX7219 - using SPI library to display 8x8 bitmap
arduino
1// Mario's Ideas 2//MAX7219 - using SPI library to display 8x8 bitmap 3#include <SPI.h> 4#define CS 7 5 6// MAX7219 Control registers 7 8#define DECODE_MODE 9 9#define INTENSITY 0x0A 10#define SCAN_LIMIT 0x0B 11#define SHUTDOWN 0x0C 12#define DISPLAY_TEST 0x0F 13 14byte Apple [8]={B00011000,B00001000,B01110110,B11111111,B11111111,B11111111,B01111010,B00110100}; 15 16void SendData(uint8_t address, uint8_t value) { 17 digitalWrite(CS, LOW); 18 SPI.transfer(address); // Send address. 19 SPI.transfer(value); // Send the value. 20 digitalWrite(CS, HIGH); // Finish transfer. 21} 22void setup() { 23 pinMode(CS, OUTPUT); 24 SPI.setBitOrder(MSBFIRST); // Most significant bit first 25 SPI.begin(); // Start SPI 26 SendData(DISPLAY_TEST, 0x01); // Run test - All LED segments lit. 27 delay(1000); 28 SendData(DISPLAY_TEST, 0x00); // Finish test mode. 29 SendData(DECODE_MODE, 0x00); // Disable BCD mode. 30 SendData(INTENSITY, 0x0e); // Use lowest intensity. 31 SendData(SCAN_LIMIT, 0x0f); // Scan all digits. 32 SendData(SHUTDOWN, 0x01); // Turn on chip. 33} 34void loop() { 35 36for (int i=1;i<9;i++) SendData(i, Apple[i-1]); 37 38}
MAX7219 - using Led Control library to display two 8x8 bitmaps
arduino
1//Mario's Ideas 2//MAX7219 - using Led Control library to display 8x8 bitmap 3#include <LedControl.h> 4 5int DIN = 11; 6int CS = 7; 7int CLK = 13; 8LedControl lc=LedControl(DIN, CLK, CS,0); 9 10int Cat[8] ={B10001000,B11111000,B10101000,B01110001,B00100001,B01111001,B01111101,B10111110 }; 11byte Apple [8]={B00011000,B00001000,B01110110,B11111111,B11111111,B11111111,B01111010,B00110100}; 12 13void setup() { 14 lc.shutdown(0,false); 15 lc.setIntensity(0,0); 16 lc.clearDisplay(0); 17} 18 19void loop(){ 20 for(int i=0;i<8;i++) lc.setRow(0,i,Apple[i]); 21 delay(5000); 22 lc.clearDisplay(0); 23 for(int i=0;i<8;i++) lc.setRow(0,i,Cat[i]); 24 delay(5000); 25 lc.clearDisplay(0); 26} 27 28
MAX7219 - using Led Control library to scroll the sample text
arduino
1// Mario's Ideas 2//MAX7219 - using Led Control library to scroll the sample text 3#include <LedControl.h> 4 5int DIN = 11; 6int CS = 7; 7int CLK = 13; 8LedControl lc=LedControl(DIN, CLK, CS,0); 9 10int position=0; 11 12int Marios_ideas [8] [54] ={ 13 {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}, 14 {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}, 15 {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}, 16 {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}, 17 {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}, 18 {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}, 19 {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}, 20 {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} 21 }; 22 23 24void setup() { 25 26 lc.shutdown(0,false); 27 lc.setIntensity(0,0); 28 lc.clearDisplay(0); 29} 30 31void loop() { 32 for (int j=0;j<8;j++){ 33 for (int i=0;i<8;i++){ 34 lc.setLed(0,i,j,Marios_ideas[j][(i+position)-abs((i+position)/54)*54]); 35 } 36 } 37 delay(20); 38 position=position+1; 39} 40
MAX7219 - using SPI library to display 8x8 bitmap
arduino
1// Mario's Ideas 2//MAX7219 - using SPI library to display 8x8 bitmap 3#include <SPI.h> 4#define CS 7 5 6// MAX7219 Control registers 7 8#define DECODE_MODE 9 9#define INTENSITY 0x0A 10#define SCAN_LIMIT 0x0B 11#define SHUTDOWN 0x0C 12#define DISPLAY_TEST 0x0F 13 14byte Apple [8]={B00011000,B00001000,B01110110,B11111111,B11111111,B11111111,B01111010,B00110100}; 15 16void SendData(uint8_t address, uint8_t value) { 17 digitalWrite(CS, LOW); 18 SPI.transfer(address); // Send address. 19 SPI.transfer(value); // Send the value. 20 digitalWrite(CS, HIGH); // Finish transfer. 21} 22void setup() { 23 pinMode(CS, OUTPUT); 24 SPI.setBitOrder(MSBFIRST); // Most significant bit first 25 SPI.begin(); // Start SPI 26 SendData(DISPLAY_TEST, 0x01); // Run test - All LED segments lit. 27 delay(1000); 28 SendData(DISPLAY_TEST, 0x00); // Finish test mode. 29 SendData(DECODE_MODE, 0x00); // Disable BCD mode. 30 SendData(INTENSITY, 0x0e); // Use lowest intensity. 31 SendData(SCAN_LIMIT, 0x0f); // Scan all digits. 32 SendData(SHUTDOWN, 0x01); // Turn on chip. 33} 34void loop() { 35 36for (int i=1;i<9;i++) SendData(i, Apple[i-1]); 37 38}
MAX7219 - using Led Control library to display all leds one by one
arduino
1//Mario's Ideas 2//MAX7219 - using Led Control library to display all leds one by one 3#include <LedControl.h> 4 5int DIN = 11; 6int CS = 7; 7int CLK = 13; 8 9LedControl lc=LedControl(DIN, CLK, CS,0); 10 11 12 13void setup() { 14 15 lc.shutdown(0,false); 16 lc.setIntensity(0,0); 17 lc.clearDisplay(0); 18} 19 20void loop() { 21 for(int j=0;j<8;j++){ 22 for(int i=0;i<8;i++){ 23 lc.setLed(0,j,i,true); 24 delay(100); 25 lc.setLed(0,j,i,false); 26 } 27 } 28}
MAX7219 - using Led Control library to display two 8x8 bitmaps
arduino
1//Mario's Ideas 2//MAX7219 - using Led Control library to display 8x8 3 bitmap 4#include <LedControl.h> 5 6int DIN = 11; 7int CS = 7; 8int CLK 9 = 13; 10LedControl lc=LedControl(DIN, CLK, CS,0); 11 12int Cat[8] ={B10001000,B11111000,B10101000,B01110001,B00100001,B01111001,B01111101,B10111110 13 }; 14byte Apple [8]={B00011000,B00001000,B01110110,B11111111,B11111111,B11111111,B01111010,B00110100}; 15 16void 17 setup() { 18 lc.shutdown(0,false); 19 lc.setIntensity(0,0); 20 lc.clearDisplay(0); 21} 22 23 24void loop(){ 25 for(int i=0;i<8;i++) lc.setRow(0,i,Apple[i]); 26 delay(5000); 27 28 lc.clearDisplay(0); 29 for(int i=0;i<8;i++) lc.setRow(0,i,Cat[i]); 30 delay(5000); 31 32 lc.clearDisplay(0); 33} 34 35
Downloadable files
Schematics
Schematics
Schematics
Schematics
Comments
Only logged in users can leave comments
mdraber
0 Followers
•0 Projects
Table of contents
Intro
14
0