binary array display with arduino
#include <LedControl.h>
const int DIN_PIN = 7;
const int CS_PIN = 6;
const int CLK_PIN = 5;
const byte IMAGES[][8] = {
{
B11111111,
B00000000,
B00000000,
B10000000,
B10000000,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B11000000,
B11000000,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B01100000,
B01100000,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B00110000,
B00110000,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B00011000,
B00011000,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B00001100,
B00001100,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B00000110,
B00000110,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B00000011,
B00000011,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B00000001,
B00000001,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B00000011,
B00000011,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B00000110,
B00000110,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B00011000,
B00011000,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B00110000,
B00110000,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B01100000,
B01100000,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B11000000,
B11000000,
B00000000,
B00000000,
B11111111
},{
B11111111,
B00000000,
B00000000,
B10000000,
B10000000,
B00000000,
B00000000,
B11111111
}};
const int IMAGES_LEN = sizeof(IMAGES)/8;
LedControl display = LedControl(DIN_PIN, CLK_PIN, CS_PIN);
void setup() {
display.clearDisplay(0);
display.shutdown(0, false);
display.setIntensity(0, 5);
}
void displayImage(const byte* image) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
display.setLed(0, i, j, bitRead(image[i], 7 - j));
}
}
}
int i = 0;
void loop() {
displayImage(IMAGES[i]);
if (++i >= IMAGES_LEN ) {
i = 0;
}
delay(333);
}