diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2024-11-04 22:03:11 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2024-11-04 22:03:11 +0800 |
| commit | 5ef1ec6262ca92417d253be8606890dd6cc34592 (patch) | |
| tree | ae929c841b222ecf85209dc0a33dae9257a35a85 /door_lock/main.c | |
| parent | 8ee098bc29cad4b5772fa39abbe3c593d4caccc0 (diff) | |
| download | smart-home-5ef1ec6262ca92417d253be8606890dd6cc34592.tar.gz | |
Btn press without debounce working.
Diffstat (limited to 'door_lock/main.c')
| -rw-r--r-- | door_lock/main.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/door_lock/main.c b/door_lock/main.c index dd19f15..9774bab 100644 --- a/door_lock/main.c +++ b/door_lock/main.c @@ -28,26 +28,15 @@ static inline uint8_t is_btn_pressed(uint8_t btn) return !((PIND >> btn) & 0x01); } -static inline uint8_t debounce(uint8_t btn) -{ - if (is_btn_pressed(btn)) { - _delay_ms(1000); - if (is_btn_pressed(btn)) - return 1; - } - - return 0; -} - int main(void) { servo_init(); for(;;) { - if (debounce(LOCK_BTN)) + if (is_btn_pressed(LOCK_BTN)) OCR1A = PWM_MID; - if (debounce(UNLOCK_BTN)) + if (is_btn_pressed(UNLOCK_BTN)) OCR1A = PWM_MIN; } |
