//**************************************************************// // Name : LoL Shield Program // // Author : Jimmie P Rodgers www.jimmieprodgers.com // // Date : 22 DEC, 2009 Last update on 12/22/09 // // Version : 0.1 // // Notes : Uses Charlieplexing techniques to light up // // : a matrix of 126 LEDs in a 9x14 grid // // : project website: www.jimmieprodgers.com/openheart // //**************************************************************// #include //This is in the Arduino library const int blinkdelay = 5; //This basically controls brightness. Lower is dimmer int runspeed = 400; //smaller = faster //29 DEC, 2009 W. Aaron Waychoff waaronw.com //ledMapBin is a map for each LED on the lolshield. Each entry corresponds to the LED number, starting with 0 (upper-left) to 125 (lower right) //the elements of this array are: //element 1: the contents that should be written to the DDRB register to set the output mode of the positive and negative pin (vals do not change pin 0&1 to preserve serial comm) //element 2: the contents that should be written to the DDRD register to set the output mode of the positive and negative pin //Note: since the pos and neg pins could be in the same or different registers, these values have the pospin and negpin bitmasks ORed together to set both pins simultaneously //element 3: the contents that should be written to the PORTB register to turn on the pospin //element 4: the contents that should be written to the PORTD register to turn on the pospin //Note: since the pospin could be in either port and we don't necessarily know in the turnonbin(), we must set both. One of these vals will always be 0 const byte ledMapBin[126][4] ={ {32, 34, 32, 0},{32, 66, 32, 0},{32, 130, 32, 0},{33, 0, 32, 0},{34, 0, 32, 0},{36, 0, 32, 0},{40, 0, 32, 0},{48, 0, 32, 0},{32, 18, 32, 0}, {32, 18, 0, 18},{32, 10, 32, 0},{32, 10, 0, 10},{32, 6, 32, 0},{32, 6, 0, 6},{16, 34, 16, 0},{16, 66, 16, 0},{16, 130, 16, 0},{17, 0, 16, 0}, {18, 0, 16, 0},{20, 0, 16, 0},{24, 0, 16, 0},{48, 0, 16, 0},{16, 18, 16, 0},{16, 18, 0, 18},{16, 10, 16, 0},{16, 10, 0, 10},{16, 6, 16, 0}, {16, 6, 0, 6},{8, 34, 8, 0},{8, 66, 8, 0},{8, 130, 8, 0},{9, 0, 8, 0},{10, 0, 8, 0},{12, 0, 8, 0},{24, 0, 8, 0},{40, 0, 8, 0}, {8, 18, 8, 0},{8, 18, 0, 18},{8, 10, 8, 0},{8, 10, 0, 10},{8, 6, 8, 0},{8, 6, 0, 6},{4, 34, 4, 0},{4, 66, 4, 0},{4, 130, 4, 0}, {5, 0, 4, 0},{6, 0, 4, 0},{12, 0, 4, 0},{20, 0, 4, 0},{36, 0, 4, 0},{4, 18, 4, 0},{4, 18, 0, 18},{4, 10, 4, 0},{4, 10, 0, 10}, {4, 6, 4, 0},{4, 6, 0, 6},{2, 34, 2, 0},{2, 66, 2, 0},{2, 130, 2, 0},{3, 0, 2, 0},{6, 0, 2, 0},{10, 0, 2, 0},{18, 0, 2, 0}, {34, 0, 2, 0},{2, 18, 2, 0},{2, 18, 0, 18},{2, 10, 2, 0},{2, 10, 0, 10},{2, 6, 2, 0},{2, 6, 0, 6},{1, 34, 1, 0},{1, 66, 1, 0}, {1, 130, 1, 0},{3, 0, 1, 0},{5, 0, 1, 0},{9, 0, 1, 0},{17, 0, 1, 0},{33, 0, 1, 0},{1, 18, 1, 0},{1, 18, 0, 18},{1, 10, 1, 0}, {1, 10, 0, 10},{1, 6, 1, 0},{1, 6, 0, 6},{0, 162, 0, 130},{0, 194, 0, 130},{1, 130, 0, 130},{2, 130, 0, 130},{4, 130, 0, 130},{8, 130, 0, 130}, {16, 130, 0, 130},{32, 130, 0, 130},{0, 146, 0, 130},{0, 146, 0, 18},{0, 138, 0, 130},{0, 138, 0, 10},{0, 134, 0, 130},{0, 134, 0, 6},{0, 98, 0, 66}, {0, 194, 0, 66},{1, 66, 0, 66},{2, 66, 0, 66},{4, 66, 0, 66},{8, 66, 0, 66},{16, 66, 0, 66},{32, 66, 0, 66},{0, 82, 0, 66},{0, 82, 0, 18}, {0, 74, 0, 66},{0, 74, 0, 10},{0, 70, 0, 66},{0, 70, 0, 6},{0, 98, 0, 34},{0, 162, 0, 34},{1, 34, 0, 34},{2, 34, 0, 34},{4, 34, 0, 34}, {8, 34, 0, 34},{16, 34, 0, 34},{32, 34, 0, 34},{0, 50, 0, 34},{0, 50, 0, 18},{0, 42, 0, 34},{0, 42, 0, 10},{0, 38, 0, 34},{0, 38, 0, 6} }; uint16_t BitMap[][9] PROGMEM = { {1, 0, 0, 0, 0, 0, 0, 0, 0}, {3, 1, 0, 0, 0, 0, 0, 0, 0}, {7, 3, 1, 0, 0, 0, 0, 0, 0}, {15, 7, 3, 1, 0, 0, 0, 0, 0}, {31, 15, 7, 3, 1, 0, 0, 0, 0}, {63, 31, 15, 7, 3, 1, 0, 0, 0}, {127, 63, 31, 15, 7, 3, 1, 0, 0}, {255, 127, 63, 31, 15, 7, 3, 1, 0}, {511, 255, 127, 63, 31, 15, 7, 3, 1}, {1023, 511, 255, 127, 63, 31, 15, 7, 3}, {2047, 1023, 511, 255, 127, 63, 31, 15, 7}, {4095, 2047, 1023, 511, 255, 127, 63, 31, 15}, {8191, 4095, 2047, 1023, 511, 255, 127, 63, 31}, {16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63}, {16383, 16383, 8191, 4095, 2047, 1023, 511, 255, 127}, {16383, 16383, 16383, 8191, 4095, 2047, 1023, 511, 255}, {16383, 16383, 16383, 16383, 8191, 4095, 2047, 1023, 511}, {16383, 16383, 16383, 16383, 16383, 8191, 4095, 2047, 1023}, {16383, 16383, 16383, 16383, 16383, 16383, 8191, 4095, 2047}, {16383, 16383, 16383, 16383, 16383, 16383, 16383, 8191, 4095}, {16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 8191}, {16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383}, {16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383}, {16382, 16383, 16383, 16383, 16383, 16383, 16383, 16383, 16383}, {16380, 16382, 16383, 16383, 16383, 16383, 16383, 16383, 16383}, {16376, 16380, 16382, 16383, 16383, 16383, 16383, 16383, 16383}, {16368, 16376, 16380, 16382, 16383, 16383, 16383, 16383, 16383}, {16352, 16368, 16376, 16380, 16382, 16383, 16383, 16383, 16383}, {16320, 16352, 16368, 16376, 16380, 16382, 16383, 16383, 16383}, {16256, 16320, 16352, 16368, 16376, 16380, 16382, 16383, 16383}, {16128, 16256, 16320, 16352, 16368, 16376, 16380, 16382, 16383}, {15872, 16128, 16256, 16320, 16352, 16368, 16376, 16380, 16382}, {15360, 15872, 16128, 16256, 16320, 16352, 16368, 16376, 16380}, {14336, 15360, 15872, 16128, 16256, 16320, 16352, 16368, 16376}, {12288, 14336, 15360, 15872, 16128, 16256, 16320, 16352, 16368}, {8192, 12288, 14336, 15360, 15872, 16128, 16256, 16320, 16352}, {0, 8192, 12288, 14336, 15360, 15872, 16128, 16256, 16320}, {0, 0, 8192, 12288, 14336, 15360, 15872, 16128, 16256}, {0, 0, 0, 8192, 12288, 14336, 15360, 15872, 16128}, {0, 0, 0, 0, 8192, 12288, 14336, 15360, 15872}, {0, 0, 0, 0, 0, 8192, 12288, 14336, 15360}, {0, 0, 0, 0, 0, 0, 8192, 12288, 14336}, {0, 0, 0, 0, 0, 0, 0, 8192, 12288}, {0, 0, 0, 0, 0, 0, 0, 0, 8192}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {18000} }; void setup() { // blinkall(2); // useful for testing } void loop() { // sequenceon(); // useful for testing blinkall(20); // DisplayBitMap(); } ////29 DEC, 2009 W. Aaron Waychoff waaronw.com //turnonbin uses the 4 elements of the LedMapBin to set the output state of pins and then turn on the appropriate pin //Probably needs to be modified not to set the output on pins 0&1 so as not to interfere with serial communication //This is already taken into account when setting the output modes in the DDRB and DDRD registers. void turnonbin(int led){ DDRB = ledMapBin[led][0]; DDRD = ledMapBin[led][1]; PORTB = ledMapBin[led][2]; PORTD = ledMapBin[led][3]; } void alloff() { DDRD = B00000010; DDRB = B00000000; } void DisplayBitMap() { boolean run=true; byte frame = 0; byte line = 0; unsigned long data; while(run == true) { for(int i = 0; i < runspeed; i++) { for(line = 0; line < 9; line++) { data = pgm_read_word_near (&BitMap[frame][line]); // fetch data from program memory if (data==18000){ run=false; } else for (byte led=0; led<14; ++led) { if (data & (1<