From c16d4508a6d59cd28095537a4d603e0629389027 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Sat, 14 Jun 2025 15:09:12 +0800 Subject: Servo is workign predictably well. --- main.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 6a07711..244a2b2 100644 --- a/main.c +++ b/main.c @@ -62,6 +62,20 @@ uint16_t getvcc(void) return vcc; } +static inline void lock(void) +{ + OCR1A = PWM_MID; + _delay_ms(100); + OCR1A = PWM_TOP; +} + +static inline void unlock(void) +{ + OCR1A = PWM_MAX; + _delay_ms(100); + OCR1A = PWM_TOP; +} + int main(void) { /* disable watchdog timer */ @@ -75,6 +89,13 @@ int main(void) LED_DDR |= (1 << LED_PIN); LED_PORT &= ~(1 << LED_PIN); + for (int i = 0; i < 4; i++) { + LED_PORT |= (1 << LED_PIN); + _delay_ms(70); + LED_PORT &= ~(1 << LED_PIN); + _delay_ms(70); + } + /* init input ports */ INPUT_DDR &= ~((1 << BACK_LOCK_PIN) | (1 << BACK_UNLOCK_PIN) | (1 << FRONT_LOCK_PIN) | (1 << FRONT_UNLOCK_PIN) | @@ -102,31 +123,11 @@ int main(void) sei(); for (;;) { - if (getvcc() < VCC_MIN) - LED_PORT |= (1 << LED_PIN); - - sleep_bod_disable(); - set_sleep_mode(SLEEP_MODE_PWR_DOWN); - sleep_mode(); } return 0; } -static inline void lock(void) -{ - OCR1A = PWM_MID; - _delay_ms(100); - OCR1A = PWM_TOP; -} - -static inline void unlock(void) -{ - OCR1A = PWM_MAX; - _delay_ms(100); - OCR1A = PWM_TOP; -} - static inline int is_pressed(uint8_t btn) { if (!((PIND >> btn) & 0x01)) { -- cgit v1.2.3