반응형
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | // 키 컨트롤 unsigned char Key_In_Data; unsigned char Key_In_Data_Old; unsigned char Key_Count; #define KEY_DEBOUNCE 30 // 키설정 #define KEY_PRESS_NO 0x73 #define KEY_PRESS_AUTO 0x72 #define KEY_PRESS_MANU 0x71 #define KEY_PRESS_Y_H 0x63 #define KEY_PRESS_M_M 0x53 #define KEY_PRESS_D_S 0x33 // 키입력 처리함수 void Key_Input(void) { static unsigned char Key_Flag; // A, B를 읽는다. Key_In_Data = PIND & 0x73; if(Key_In_Data == Key_In_Data_Old) { if(++Key_Count > KEY_DEBOUNCE && Key_Flag == 0) { Key_Flag = 1; Key_Count = KEY_DEBOUNCE + 1; // 키처리 switch(Key_In_Data) { case KEY_PRESS_NO : // 아무것도 안눌렸을때 break; case KEY_PRESS_AUTO : Led_Status ^= LED_AUTO; break; case KEY_PRESS_MANU : Led_Status ^= LED_MANU; break; case KEY_PRESS_Y_H : Led_Status ^= LED_Y_H; break; case KEY_PRESS_M_M : Led_Status ^= LED_M_M; break; case KEY_PRESS_D_S : Led_Status ^= LED_D_S; break; } } } else { Key_Count = 0; Key_Flag = 0; } Key_In_Data_Old = Key_In_Data; } | cs |
반응형
'개발모듈 > 펌웨어 모듈' 카테고리의 다른 글
- Key Control 5 (0) | 2019.12.11 |
---|---|
- Data_Send 함수 (0) | 2019.12.10 |
- [AVR Studio 4] printf 함수 사용하기 (0) | 2019.06.09 |
- [AVR Studio4] ADC 8비트 (0) | 2019.06.04 |
- Key Control 3 (0) | 2019.04.08 |