Rising1 [AVR] atmega1281 - switch로 LED 점멸 제어 #define LED1 PC0#define LED2 PC1#define LED3 PC2#define LED4 PC3#define SW2 PE7#include uint8_t switch_hit();int main(void){ static unsigned char cnt; DDRC = _BV(LED1) | _BV(LED2) | _BV(LED3) | _BV(LED4); PORTE = _BV(SW2); while(1) { if(switch_hit()) { cnt++; if(cnt % 2) // turn on LED1 and LED2 and turn off LED3 and LED4 else // turn on LED3 and LED4 and turn off LED1 and LED2 .. 2024. 10. 2. 이전 1 다음