From 5ef1ec6262ca92417d253be8606890dd6cc34592 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Mon, 4 Nov 2024 22:03:11 +0800 Subject: Btn press without debounce working. --- door_lock/main.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'door_lock') 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; } -- cgit v1.2.3