LOL SHIELD

I made a short animation simulating rain/matrix effect in the lol shield.

CODE:

#include <avr/pgmspace.h>
#include <Charliplexing.h>

int blinkdelay = 100; //Sets the time each frame is shown

uint16_t BitMap[][9] PROGMEM = {
{ 16383 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 },

{ 16383 ,
4642 ,
514 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 },

{ 16383 ,
5802 ,
4770 ,
4642 ,
514 ,
0 ,
0 ,
0 ,
0 },

{ 16383 ,
12013 ,
16111 ,
5802 ,
4770 ,
4642 ,
514 ,
0 ,
0 },

{ 16367 ,
14333 ,
16383 ,
16111 ,
16111 ,
5802 ,
4770 ,
4642 ,
514 },

{ 16383 ,
12215 ,
16381 ,
15359 ,
16383 ,
16111 ,
16111 ,
5802 ,
4770 },

{ 16383 ,
14303 ,
15863 ,
12157 ,
15359 ,
16343 ,
16383 ,
16111 ,
15087 },

{ 16383 ,
14303 ,
13783 ,
9557 ,
10613 ,
11093 ,
15319 ,
16071 ,
15087 },

{ 16383 ,
14303 ,
13783 ,
9557 ,
8533 ,
8533 ,
10581 ,
10821 ,
15047 },

{ 7613 ,
14303 ,
13783 ,
9557 ,
8533 ,
8533 ,
8533 ,
8261 ,
10309 },

{ 7613 ,
5533 ,
5525 ,
10071 ,
8535 ,
8533 ,
8533 ,
8261 ,
8261 },

{ 7613 ,
5533 ,
5525 ,
10071 ,
8535 ,
8533 ,
8533 ,
8261 ,
8261 },

{ 0 ,
0 ,
7613 ,
5533 ,
5525 ,
10071 ,
8535 ,
8533 ,
8533 },

{ 0 ,
0 ,
0 ,
0 ,
7613 ,
5533 ,
5525 ,
10071 ,
8535 },

{ 0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
7613 ,
5533 ,
5525 },

{ 0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
7613 },
{18000}
};

void setup() {
LedSign::Init(); //Initializes the screen
}
void loop() {
DisplayBitMap(); //Displays the bitmap
}

void DisplayBitMap()
{
boolean run=true; //While this is true, the screen updates
byte frame = 0; //Frame counter
byte line = 0; //Row counter
unsigned long data; //Temporary storage of the row data

while(run == true) {
for(line = 0; line < 9; line++) {

//Here we fetch data from program memory with a pointer.
data = pgm_read_word_near (&BitMap[frame][line]);

//Kills the loop if the kill number is found
if (data==18000){
run=false;
}

//This is where the bit-shifting happens to pull out
//each LED from a row. If the bit is 1, then the LED
//is turned on, otherwise it is turned off.
else for (byte led=0; led<14; ++led) {
if (data & (1<<led)) {
LedSign::Set(led, line, 1);
}
else {
LedSign::Set(led, line, 0);
}
}

}

//Delays the next update
delay(blinkdelay);
frame++;
}
}

Leave a Reply

Your email address will not be published.