Created
June 7, 2019 20:50
-
-
Save titimoby/c29f19e7ade8a3c634f66837a2bf4edb to your computer and use it in GitHub Desktop.
trying spi matrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Gamebuino-Meta.h> | |
#include <LedControl.h> | |
// Pin Definitions | |
#define PIN_DIN MISO | |
#define PIN_CLK MOSI | |
#define PIN_CS 4 | |
/* | |
Now we need a LedControl to work with. | |
***** These pin numbers will probably not work with your hardware ***** | |
pin PIN_DIN is connected to the DataIn | |
pin PIN_CLK is connected to the CLK | |
pin PIN_CS is connected to LOAD | |
We have only a single MAX72XX. | |
*/ | |
LedControl lc=LedControl(PIN_DIN,PIN_CLK,PIN_CS,1); | |
/* we always wait a bit between updates of the display */ | |
unsigned long delaytime=1000; | |
byte I[] = { B00000000, | |
B00000000, | |
B00000000, | |
B11111111, | |
B11111111, | |
B00000000, | |
B00000000, | |
B00000000 }; | |
byte J[] = { B00000000, | |
B00000000, | |
B01100000, | |
B01100000, | |
B01111110, | |
B01111110, | |
B00000000, | |
B00000000 }; | |
byte L[] = { B00000000, | |
B00000000, | |
B00000110, | |
B00000110, | |
B01111110, | |
B01111110, | |
B00000000, | |
B00000000 }; | |
byte O[] = { B00000000, | |
B00000000, | |
B00111100, | |
B00111100, | |
B00111100, | |
B00111100, | |
B00000000, | |
B00000000 }; | |
byte S[] = { B00000000, | |
B00011110, | |
B00011110, | |
B00011000, | |
B00011000, | |
B01111000, | |
B01111000, | |
B00000000 }; | |
byte T[] = { B00000000, | |
B00000000, | |
B00011000, | |
B00011000, | |
B01111110, | |
B01111110, | |
B00000000, | |
B00000000 }; | |
byte Z[] = { B00000000, | |
B01111000, | |
B01111000, | |
B00011000, | |
B00011000, | |
B00011110, | |
B00011110, | |
B00000000 }; | |
void setup() { | |
gb.begin(); | |
/* | |
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,8); | |
/* and clear the display */ | |
lc.clearDisplay(0); | |
} | |
void printPiece(byte piece[]) { | |
for (int i=0; i<8; i++) { | |
lc.setRow(0,i, piece[i]); | |
} | |
} | |
void loop() { | |
printPiece(I); | |
delay(delaytime); | |
printPiece(J); | |
delay(delaytime); | |
printPiece(L); | |
delay(delaytime); | |
printPiece(O); | |
delay(delaytime); | |
printPiece(S); | |
delay(delaytime); | |
printPiece(T); | |
delay(delaytime); | |
printPiece(Z); | |
delay(delaytime); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment