Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
LED Cube Code
int latchPin = 1;
int clockPin = 0;
int dataPin = 2;
//kek, last column is on pin 3
int powers[] = {0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072};
char a[][5][5] = {{{B00000, B00000, B00000, B00000, B00000},{B00010, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00110, B00000, B00000, B00000, B00000},{B00110, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00110, B00100, B00000, B00000, B00000},{B00110, B00100, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00110, B00110, B00000, B00000, B00000},{B00110, B00110, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B01100, B01100, B00000, B00000, B00000},{B01100, B01100, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B01100, B01100, B00000, B00000, B00000},{B01100, B01100, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B01100, B01100, B00000, B00000},{B00000, B01100, B01100, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B01100, B01100, B00000},{B00000, B00000, B01100, B01100, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00110, B00110, B00000},{B00000, B00000, B00110, B00110, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00010, B00110, B01110, B00000},{B00000, B00010, B00110, B01110, B00000},{B00000, B00000, B00010, B00110, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00110, B01110, B01110, B00000},{B00000, B00110, B01110, B01110, B00000},{B00000, B00010, B00110, B01110, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B01110, B01110, B01110, B00000},{B00000, B01110, B01110, B01110, B00000},{B00000, B00110, B01110, B01110, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B01110, B01110, B01110, B00000},{B00000, B01110, B01110, B01110, B00000},{B00000, B01110, B01110, B01110, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B11100, B11100, B11100, B00000},{B00000, B11100, B11100, B11100, B00000},{B00000, B11100, B11100, B11100, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B11100, B11100, B11100, B00000},{B00000, B11100, B11100, B11100, B00000},{B00000, B11100, B11100, B11100, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B11100, B11100, B11100, B00000},{B00000, B11100, B11100, B11100, B00000},{B00000, B11000, B11100, B11100, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B11100, B11100, B11100, B00000},{B00000, B11000, B11100, B11100, B00000},{B00000, B10000, B11000, B11100, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B11000, B11100, B11100, B00000},{B00000, B10000, B11000, B11100, B00000},{B00000, B00000, B10000, B11000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B10000, B11000, B11100, B00000},{B00000, B00000, B10000, B11000, B00000},{B00000, B00000, B00000, B10000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B10000, B11000, B00000},{B00000, B00000, B00000, B10000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B10000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B10000, B10000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B10000, B10000, B10000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B10000, B10000, B10000, B10000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11000, B10000, B10000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11100, B10000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11100, B00000, B00000, B00000, B00000},{B00100, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B01100, B00000, B00000, B00000, B00000},{B00110, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00100, B00000, B00000, B00000, B00000},{B00110, B00010, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00110, B00010, B00010, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00010, B00010, B00010, B00010, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00010, B00010, B00110, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00010, B01110, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B11110, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B11100, B00000},{B00000, B00000, B00000, B10000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B11000, B00000},{B00000, B00000, B10000, B10000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B10000, B00000},{B00000, B00000, B11000, B10000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B11100, B10000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B11110, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00010, B01110, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00010, B00010, B00110, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00010, B00010, B00010, B00000, B00000},{B00010, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00010, B00010, B00000, B00000, B00000},{B00110, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00010, B00000, B00000, B00000, B00000},{B01110, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B11110, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B11100, B10000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B11000, B11000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B10000, B11100, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B11110, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00010, B00000, B00000, B00000},{B00000, B01110, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00000, B00000, B00000, B00000},{B00000, B00010, B00000, B00000, B00000},{B00000, B00010, B00000, B00000, B00000},{B00000, B00110, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00010, B00000, B00000, B00000},{B00000, B00010, B00000, B00000, B00000},{B00000, B00010, B00000, B00000, B00000},{B00000, B00010, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00010, B00010, B00000, B00000, B00000},{B00000, B00010, B00000, B00000, B00000},{B00000, B00010, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00110, B00010, B00000, B00000, B00000},{B00000, B00010, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B01110, B00010, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11110, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11110, B10000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11110, B11000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11110, B11100, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11110, B11110, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11110, B11110, B00010, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11110, B11110, B00110, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11110, B11110, B01110, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11110, B11110, B11110, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11110, B11110, B11110, B10000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11110, B11110, B11110, B11000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11110, B11110, B11110, B11100, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11110, B11110, B11110, B11110, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B11110, B11110, B11110, B11110, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B01110, B01110, B01110, B01110, B00000},{B10000, B10000, B10000, B10000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00110, B00110, B00110, B00110, B00000},{B01000, B01000, B01000, B01000, B00000},{B10000, B10000, B10000, B10000, B00000},{B00000, B00000, B00000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00010, B00010, B00010, B00010, B00000},{B00100, B00100, B00100, B00100, B00000},{B01000, B01000, B01000, B01000, B00000},{B10000, B10000, B10000, B10000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00010, B00010, B00010, B00010, B00000},{B00010, B00010, B00010, B00010, B00000},{B00100, B00100, B00100, B00100, B00000},{B01000, B01000, B01000, B01000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00010, B00010, B00010, B00010, B00000},{B00010, B00010, B00010, B00010, B00000},{B00010, B00010, B00010, B00010, B00000},{B00100, B00100, B00100, B00100, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00010, B00010, B00010, B00010, B00000},{B00010, B00010, B00010, B00010, B00000},{B00010, B00010, B00010, B00010, B00000},{B00010, B00010, B00010, B00010, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00100, B00010, B00010, B00010, B00000},{B00100, B00010, B00010, B00010, B00000},{B00100, B00010, B00010, B00010, B00000},{B00100, B00010, B00010, B00010, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B01000, B00100, B00010, B00010, B00000},{B01000, B00100, B00010, B00010, B00000},{B01000, B00100, B00010, B00010, B00000},{B01000, B00100, B00010, B00010, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B10000, B01000, B00100, B00010, B00000},{B10000, B01000, B00100, B00010, B00000},{B10000, B01000, B00100, B00010, B00000},{B10000, B01000, B00100, B00010, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B11000, B00110, B00000, B00000},{B00000, B11000, B00110, B00000, B00000},{B00000, B11000, B00110, B00000, B00000},{B00000, B11000, B00110, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00110, B11000, B00000, B00000},{B00000, B00110, B11000, B00000, B00000},{B00000, B00110, B11000, B00000, B00000},{B00000, B00110, B11000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00010, B00100, B01000, B10000, B00000},{B00010, B00100, B01000, B10000, B00000},{B00010, B00100, B01000, B10000, B00000},{B00010, B00100, B01000, B10000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00100, B00100, B01000, B01000, B00000},{B00100, B00100, B01000, B01000, B00000},{B00100, B00100, B01000, B01000, B00000},{B00100, B00100, B01000, B01000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B01000, B01000, B00100, B00100, B00000},{B01000, B01000, B00100, B00100, B00000},{B01000, B01000, B00100, B00100, B00000},{B01000, B01000, B00100, B00100, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B10000, B01000, B00100, B00010, B00000},{B10000, B01000, B00100, B00010, B00000},{B10000, B01000, B00100, B00010, B00000},{B10000, B01000, B00100, B00010, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B11000, B00110, B00000, B00000},{B00000, B11000, B00110, B00000, B00000},{B00000, B11000, B00110, B00000, B00000},{B00000, B11000, B00110, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00110, B11000, B00000, B00000},{B00000, B00110, B11000, B00000, B00000},{B00000, B00110, B11000, B00000, B00000},{B00000, B00110, B11000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00010, B00100, B01000, B10000, B00000},{B00010, B00100, B01000, B10000, B00000},{B00010, B00100, B01000, B10000, B00000},{B00010, B00100, B01000, B10000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B10000, B01000, B00100, B00010, B00000},{B10000, B01000, B00100, B00010, B00000},{B10000, B01000, B00100, B00010, B00000},{B10000, B01000, B00100, B00010, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B11000, B00110, B00000, B00000},{B00000, B11000, B00110, B00000, B00000},{B00000, B11000, B00110, B00000, B00000},{B00000, B11000, B00110, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}},{{B00000, B00110, B11000, B00000, B00000},{B00000, B00110, B11000, B00000, B00000},{B00000, B00110, B11000, B00000, B00000},{B00000, B00110, B11000, B00000, B00000},{B00000, B00000, B00000, B00000, B00000}}};
void setup() {
//set pins to output so you can control the shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
//pin 3 for last column
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
}
//prints actual output
void printOutput(bool toPrint[5][25], int layer)
{
digitalWrite(latchPin, LOW);
bool found = false;
for(int x = 2; x >= 0; x--)
{
int number = 0;
if (!found)
{
for(int y = 0; y < 8; y++)
{
bool currentBit = toPrint[layer][x*8+y];
if (currentBit)
{
found = true;
number += powers[y+1];
}
}
}
shiftOut(dataPin, clockPin, MSBFIRST, number);
}
digitalWrite(latchPin, HIGH);
if (toPrint[layer][3*8])
digitalWrite(3, HIGH);
else
digitalWrite(3, LOW);
}
//splits pattern in to seperate bits to print
//can't print more than one bit at once
void printPattern(char toPrint[5][5])
{
bool singleArray[5][25] = {
{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,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,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,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,0,0,0,0, 0,0,0,0,0}
};
for (int layer = 0; layer < 5; layer++)
{
digitalWrite(8-layer, LOW);
for (int placeByte = 0; placeByte < 5; placeByte++)
{
for (int placeBit = 0; placeBit < 5; placeBit++)
{
bool thisBit = ((toPrint[layer][placeByte] >> placeBit) & 0x01);
if (thisBit)
{
singleArray[layer][placeByte*5+placeBit] = 1;
printOutput(singleArray, layer);
singleArray[layer][placeByte*5+placeBit] = 0;
}
}
}
printOutput(singleArray, layer);
digitalWrite(8-layer, HIGH);
}
}
void loop() {
for (int w = 0; w < 90; w++)
{
for (int repeat = 0; repeat < 40; repeat++)
{
printPattern(a[w]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.