/* Based on https://github.com/maltesemanTS1/Charlieplexing-the-Arduino http://arduino.cc/en/Tutorial/BitMask */ #define PRADC 0 #define PRR _SFR_IO8(0x25) unsigned long previousMillis = 0; // will store last time LED was updated unsigned long currentMillis = 0; byte frame = 0; byte animation_index = 0; const byte animation_index_max = 6; //const uint16_t fade_repeat = 8192; //const uint16_t fade2_repeat = 16000; //const uint16_t data_repeat = 512; // //const unsigned long fade_delay = 1500; //const unsigned long fade2_delay = 2500; //const unsigned long data_delay = 400; const uint16_t fade_repeat = 1000; const uint16_t fade2_repeat = 2000; const uint16_t data_repeat = 64; const uint16_t fade_delay = 2500; const uint16_t fade2_delay = 3500; const uint16_t data_delay = 400; const byte data_length = 29; const byte kitt_text[data_length] PROGMEM = { 0xFE, 0x10, 0x28, 0x44, 0x82, // K 0x00, 0x80, 0x00, // . 0x82, 0xFE, 0x82, // I 0x00, 0x80, 0x00, // . 0x02, 0x02, 0xFE, 0x02, 0x82, // T 0x00, 0x80, 0x00, // . 0x02, 0x02, 0xFE, 0x02, 0x82, // T 0x00, 0x80 // . }; const byte fade_length = 19; const byte scanner[fade_length] PROGMEM = { 0x80, 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, 0x01, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80 }; const byte fade2_length = 7; const byte cross_scanner[fade2_length] PROGMEM = { 0x81, 0x42, 0x24, 0x18, 0x24, 0x42, 0x81 }; const byte fade3_length = 9; const byte cross_scanner_full[fade3_length] PROGMEM = { 0x81, 0x42, 0x24, 0x18, 0x18, 0x3C, 0x7E, 0xFF, 0xFF }; const byte fade4_length = 11; const byte police_flasher[fade4_length] PROGMEM = { 0xF0, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0x0F, 0x00, 0x0F, 0x00, 0x0F }; void setup() { PRR |= (uint8_t)(1 << PRADC); // ADCSRA &= ~(1<= ani_delay) { for (byte i = 0; i < arr_length; i++) { // save the last time you blinked the LED previousMillis = currentMillis; frame = pgm_read_byte_near(arr + i); show_frame(arr_repeat); } } else { charlie(255); } } void check_button_state() { if ( !(PINB & (1 << PB4)) ) { animation_index++; // reset if out of range if (animation_index > animation_index_max) { animation_index = 0; } frame = 0; // saves storage blink_led(); blink_led(); blink_led(); // reset animation timer previousMillis = currentMillis; } }