diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2025-06-14 15:09:12 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2025-06-14 15:09:12 +0800 |
| commit | c16d4508a6d59cd28095537a4d603e0629389027 (patch) | |
| tree | 4e284deec81176d90afcbf55bdee520817cb95ac | |
| parent | d03bca4d47f16efd5cd081864b45f7dc2afd0dee (diff) | |
| download | fpm-door-lock-c16d4508a6d59cd28095537a4d603e0629389027.tar.gz | |
Servo is workign predictably well.
| -rw-r--r-- | main.c | 41 |
1 files changed, 21 insertions, 20 deletions
@@ -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)) { |
