summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-06-14 15:09:12 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-06-14 15:09:12 +0800
commitc16d4508a6d59cd28095537a4d603e0629389027 (patch)
tree4e284deec81176d90afcbf55bdee520817cb95ac
parentd03bca4d47f16efd5cd081864b45f7dc2afd0dee (diff)
downloadfpm-door-lock-c16d4508a6d59cd28095537a4d603e0629389027.tar.gz
Servo is workign predictably well.
-rw-r--r--main.c41
1 files changed, 21 insertions, 20 deletions
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)) {