/* Illuminated Button Matrix David Johnson-Davies - www.technoblogy.com - 9th May 2019 ATtiny88 @ 8MHz (internal oscillator; BOD disabled) CC BY 4.0 Licensed under a Creative Commons Attribution 4.0 International license: http://creativecommons.org/licenses/by/4.0/ */ #include volatile int Lights; // One bit per light; bit 0 = Button 1 etc. volatile int Keys; // One bit per key; bit 0 = Button 1 etc. int Row; // INT pin ********************************************** const int IntPin = PORTC7; inline void IntLow () { PORTC = PORTC & ~(1<>8 & 0xFF); IntRelease(); } // Keys ********************************************** void SetupKeys () { // Set up pin change interrupts on the keys DDRB = 0; PORTB = 0xFF; // Port B all input pullups DDRD = 0; PORTD = 0xFF; // Port D all input pullups PCMSK0 = 0xFF; PCMSK2 = 0xFF; // Enable PB0 to PB7 and PD0 to PD7 PCIFR = 1< 250Hz TIMSK1 = TIMSK1 | 1<>(Row*4) & 0x0F; PORTA = ~Bits; PORTC = PORTC | 1<