Created
March 17, 2020 12:47
-
-
Save cirias/84051a274b0c231bf0315bcdcf33dddf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#define PIN01 9 | |
#define PIN02 8 | |
#define PIN03 7 | |
#define PIN04 6 | |
#define PIN05 5 | |
#define PIN06 4 | |
#define PIN07 3 | |
#define PIN08 2 | |
#define PIN09 11 | |
#define PIN10 10 | |
#define PIN11 A5 | |
#define PIN12 A4 | |
#define PIN13 A3 | |
#define PIN14 A2 | |
#define PIN15 A1 | |
#define PIN16 A0 | |
#define EDGE_SIZE 8 | |
// default to HIGH | |
const byte row[EDGE_SIZE] = { | |
PIN16, PIN15, PIN11, PIN06, PIN09, PIN04, PIN03, PIN13 | |
}; | |
// default to LOW | |
const byte col[EDGE_SIZE] = { | |
PIN10, PIN14, PIN08, PIN12, PIN01, PIN07, PIN02, PIN05 | |
}; | |
const byte frames[][EDGE_SIZE][EDGE_SIZE] = { | |
{ | |
{ 0, 0, 0, 0, 0, 0, 0, 0, }, | |
{ 0, 0, 0, 0, 0, 0, 0, 0, }, | |
{ 0, 0, 1, 0, 0, 1, 0, 0, }, | |
{ 0, 1, 3, 3, 3, 3, 1, 0, }, | |
{ 0, 1, 3, 4, 4, 3, 1, 0, }, | |
{ 0, 0, 1, 3, 3, 1, 0, 0, }, | |
{ 0, 0, 0, 1, 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, 0, 1, 0, 0, 1, 0, 0, }, | |
{ 0, 1, 3, 3, 3, 3, 1, 0, }, | |
{ 0, 1, 3, 4, 4, 3, 1, 0, }, | |
{ 0, 0, 1, 3, 3, 1, 0, 0, }, | |
{ 0, 0, 0, 1, 1, 0, 0, 0, }, | |
{ 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 0, 0, 0, 0, 0, }, | |
},{ | |
{ 0, 0, 0, 0, 0, 0, 0, 0, }, | |
{ 0, 4, 4, 0, 0, 4, 4, 0, }, | |
{ 4, 4, 4, 4, 4, 4, 4, 4, }, | |
{ 4, 4, 4, 4, 4, 4, 4, 4, }, | |
{ 4, 4, 4, 4, 4, 4, 4, 4, }, | |
{ 0, 4, 4, 4, 4, 4, 4, 0, }, | |
{ 0, 0, 4, 4, 4, 4, 0, 0, }, | |
{ 0, 0, 0, 4, 4, 0, 0, 0, }, | |
}, | |
}; | |
const byte frames_count = sizeof(frames) / EDGE_SIZE / EDGE_SIZE; | |
const byte loop_count = 2*frames_count - 2; | |
void setup() | |
{ | |
// Open serial port | |
Serial.begin(9600); | |
// Set all used pins to OUTPUT | |
// This is very important! If the pins are set to input | |
// the display will be very dim. | |
for (byte i = 0; i < EDGE_SIZE; i++) { | |
pinMode(row[i], OUTPUT); | |
digitalWrite(row[i], HIGH); | |
} | |
for (byte i = 0; i < EDGE_SIZE; i++) { | |
pinMode(col[i], OUTPUT); | |
digitalWrite(col[i], LOW); | |
} | |
} | |
byte cursor = 0; | |
void loop() { | |
byte fi = cursor < frames_count ? cursor : loop_count-cursor; | |
auto frame = frames[fi]; | |
for (byte i = 0; i < 150; i++) { | |
byte level = i % 4; | |
for (byte r = 0; r < EDGE_SIZE; r++) { | |
digitalWrite(row[r], LOW); | |
for (byte c = 0; c < EDGE_SIZE; c++) { | |
byte grade = frame[r][c]; | |
digitalWrite(col[c], grade > level ? HIGH : LOW); | |
digitalWrite(col[c], LOW); | |
} | |
digitalWrite(row[r], HIGH); | |
} | |
} | |
cursor = (cursor + 1) % loop_count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment