/* I2C Display Module ATtinyx41, B.O.D. Disabled, ATtiny841, 1 MHz (internal) David Johnson-Davies - www.technoblogy.com - 5th August 2016 CC BY 4.0 Licensed under a Creative Commons Attribution 4.0 International license: http://creativecommons.org/licenses/by/4.0/ */ // Seven-segment definitions char charArray[] = { // ABCDEFG Segments 0b1111110, // 0 0b0110000, // 1 0b1101101, // 2 0b1111001, // 3 0b0110011, // 4 0b1011011, // 5 0b1011111, // 6 0b1110000, // 7 0b1111111, // 8 0b1111011, // 9 0b1110111, // 10 "A" 0b0011111, // 11 "B" 0b1001110, // 12 "C" 0b0111101, // 13 "D" 0b1001111, // 14 "E" 0b1000111, // 15 "F" 0b0000000, // 16 Space 0b0000001 // 17 '-' }; const int I2CAddress = 0x3A; const int Blank = 16; const int Dash = 17; volatile int Buffer[] = {Dash, Dash}; volatile int Write = 0; volatile int Read = 0; int Digit = 0; // Pin assignments int Digits[] = {PORTA5, PORTA7}; // Display multiplexer ********************************************** void DisplayNextDigit() { Digit = Digit ^ 1; // Toggle between 0 and 1 int segs = charArray[Buffer[Digit]]; DDRA = 0; DDRB = 0; // All inputs // Set display segments PORTA = 0; PORTB = 0; DDRB = segs & 0x07; // Outputs DDRA = (segs>>3) & 0x0F; DDRA = DDRA | 1<