#include #include #define LED_STATUS PC0 #define LED_GREEN PC1 #define LED_RED PC2 #define BUZZER PC3 #define RELAIS PC4 #define LED_STATUS_ON PORTC &= ~(1 << LED_STATUS) #define LED_GREEN_ON PORTC &= ~(1 << LED_GREEN) #define LED_RED_ON PORTC &= ~(1 << LED_RED) #define BUZZER_ON PORTC &= ~(1 << BUZZER) #define RELAIS_ON PORTC &= ~(1 << RELAIS) #define LED_STATUS_OFF PORTC |= (1 << LED_STATUS) #define LED_GREEN_OFF PORTC |= (1 << LED_GREEN) #define LED_RED_OFF PORTC |= (1 << LED_RED) #define BUZZER_OFF PORTC |= (1 << BUZZER) #define RELAIS_OFF PORTC |= (1 << RELAIS) #define isStatusLedOn ((PORTC & (1 << LED_STATUS)) == LED_STATUS) #define isGREENLedOn ((PORTC & (1 << LED_GREEN)) == LED_GREEN) #define isREDLedOn ((PORTC & (1 << LED_RED)) == LED_RED) #define isBuzzerOn ((PORTC & (1 << BUZZER)) == BUZZER) #define isRelaisOn ((PORTC & (1 << RELAIS)) == RELAIS) SIGNAL (SIG_OVERFLOW0) { if (isStatusLedOn) LED_STATUS_OFF; else LED_STATUS_ON; } void init_hardware(void) { DDRC = 0xFF; TCCR0 = (1 << CS00) | (1 << CS02); TIMSK = (1 << TOIE0); PORTC = 0x02; } void main (void) { init_hardware(); sei(); while (1) { if (isStatusLedOn) LED_GREEN_ON; else LED_GREEN_OFF; if(isGREENLedOn) LED_RED_ON; else LED_RED_OFF; if(isREDLedOn) RELAIS_ON; else RELAIS_OFF; if (isRelaisOn) BUZZER_ON; else BUZZER_OFF; } }