summaryrefslogtreecommitdiffstats
path: root/door_lock/main.c
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2024-11-03 14:16:32 +0800
committerSadeep Madurange <sadeep@asciimx.com>2024-11-03 14:16:32 +0800
commit0c1f7fef8447da32a94c7b6784edd9a6b3a12428 (patch)
tree5120196e2748f7fb7d35a0b1178d312fb3accb7b /door_lock/main.c
parent92807aed3d3dc17fdf94d35d8b26c1d894aab9f2 (diff)
downloadsmart-home-0c1f7fef8447da32a94c7b6784edd9a6b3a12428.tar.gz
Serial console.
Diffstat (limited to 'door_lock/main.c')
-rw-r--r--door_lock/main.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/door_lock/main.c b/door_lock/main.c
index 7308d35..4ee0e64 100644
--- a/door_lock/main.c
+++ b/door_lock/main.c
@@ -1,25 +1,25 @@
#include <avr/io.h>
#include <util/delay.h>
-int main(void) {
- DDRB |= 1 << PINB1; // Set pin 9 on arduino to output
+#include "serial.h"
- /* 1. Set Fast PWM mode 14: set WGM11, WGM12, WGM13 to 1 */
- /* 3. Set pre-scaler of 8 */
- /* 4. Set Fast PWM non-inverting mode */
+int main(void) {
+ // pin 9
+ DDRB |= 1 << PINB1;
TCCR1A |= (1 << WGM11) | (1 << COM1A1);
TCCR1B |= (1 << WGM12) | (1 << WGM13) | (1 << CS11);
- /* 2. Set ICR1 register: PWM period */
ICR1 = 39999;
-
- /* Offset for correction */
int offset = 800;
- /* 5. Set duty cycle */
- while(1) {
+ serial_init();
+
+ for(;;) {
+ serial_write("hello, world!");
+
OCR1A = 3999 + offset;
_delay_ms(5000);
+
OCR1A = 1999 - offset;
_delay_ms(5000);
}