/* ========================================================================== */ /* */ /* Filename.c */ /* (c) 2001 Author */ /* */ /* Description */ /* */ /* ========================================================================== */ #include #include #include uint8_t pina; uint8_t pinb; ISR(PCINT0_vect){ uint8_t difa = (pina ^ PINA) & PINA; uint8_t difb = (pinb ^ PINB) & PINB; if (difa == 1) { // S1 gedrückt -> aktiviere Blau ? PORTB = PORTB ^ 4; } else if (difa == 2) { // S2 gedrückt -> aktiviere ?? PORTA = PORTA ^ 128; } else if (difa == 4) { // S3 gedrückt -> aktiviere ?? PORTA = PORTA ^ 64; } else if (difa == 8) { // S4 gedrückt -> alle an PORTA |= (1 << PORTA6) | (1 << PORTA7); PORTB |= (1 << PORTB2); } else if (difb == 1 || difb == 2) { // S5 oder S6 gedrückt -> alle aus PORTA = (1 << PORTA4) | (1 << PORTA5); PORTB = (1 << PORTB3); } pina = PINA; pinb = PINB; } // Set fuses for 8MHz internal clock with slow rising power FUSES = { .low = (FUSE_SUT1 & FUSE_CKSEL3 & FUSE_CKSEL2 & FUSE_CKSEL0), .high = FUSE_SPIEN, .extended = EFUSE_DEFAULT }; int main() { // Set A7, A6 and B2 as output DDRA = (1 << DDA7) | (1 << DDA6); DDRB = (1 << DDB2); PORTB = 0; PORTA = 0; pina = PINA; pinb = PINB; // Enable Pin Change Interrupts for switches GIMSK = (1 << PCIE1) | (1 << PCIE0); PCMSK0 = (1 << PCINT0) | (1 << PCINT1) | (1 << PCINT2) | (1 << PCINT3); PCMSK1 = (1 << PCINT8) | (1 << PCINT9); sei(); while (1) { sleep_enable(); } return 0; }