diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2025-07-25 11:11:58 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2025-07-25 11:11:58 +0800 |
| commit | 8ec701c2117d9e07678c393d98b74414ad112837 (patch) | |
| tree | c0565edfa4b4cdf043e4cd856eb7e4c7b518dc19 | |
| parent | 6f542c534e499ccfe4d0cfa473f54c7cb438edd6 (diff) | |
| download | fpm-door-lock-8ec701c2117d9e07678c393d98b74414ad112837.tar.gz | |
wip: move the servo incrementally.
| -rw-r--r-- | main.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -13,6 +13,7 @@ #define PWM_MID 1600 #define PWM_MAX 2550 #define PWM_TOP 19999 +#define PWM_DELTA 50 #define LED_PIN PB5 #define LED_DDR DDRB @@ -54,14 +55,22 @@ static volatile enum CTRL cmd = NONE; static inline void lock(void) { - OCR1A = PWM_MID; - _delay_ms(500); + int pwm; + + for (pwm = PWM_MID + PWM_DELTA; pwm < PWM_MAX; pwm += PWM_DELTA) { + OCR1A = pwm; + _delay_ms(50); + } } static inline void unlock(void) { - OCR1A = PWM_MAX; - _delay_ms(500); + int pwm; + + for (pwm = PWM_MAX - PWM_DELTA; pwm > PWM_MID; pwm -= PWM_DELTA) { + OCR1A = pwm; + _delay_ms(50); + } } static inline void flash_led(void) |
