Switch2 [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. [AVR] atmega1281 - switch / delay 함수 새로운 자료형C의 data type의 변수 길이는 MCU에 따라 달라진다. - sizeof(short) ≤ sizeof(int) ≤ sizeof(long) // 기본 - 8bit MCU : sizeof(int)= 2 / 32bit MCU: sizeof(int)= 4 / 64bit CPU: sizeof(int)= 8 https://www.ibm.com/docs/ko/i/7.5?topic=files-stdinth 포함 파일은 너비를 지정하고 해당 매크로 세트를 정의하는 정수 유형 세트를 선언합니다. 또한 다른 표준 포함 파일에 정의된 유형에 대응하는 정수 유형의 한계를 지정하는 매크로도 www.ibm.com변수 선언 때 변수나 상수의 길이를 명시할 필요가 있음 - Embedded software 개발 시 흔.. 2024. 9. 30. 이전 1 다음