-
Notifications
You must be signed in to change notification settings - Fork 0
/
alarm.ino
56 lines (48 loc) · 990 Bytes
/
alarm.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <Servo.h>
#include <TimeAlarms.h>
#include <TimeLib.h>
Servo servo;
AlarmId id;
void setup() {
Serial.begin(9600);
servo.attach(8);
servo.write(0);
Alarm.delay(2000);
setTime(15,20,0,1,1,11);
Alarm.alarmRepeat(11,00,0, MorningAlarm);
}
void loop(){
digitalClockDisplay();
Alarm.delay(1000); // wait one second between clock display
}
void MorningAlarm() {
servo.write(0);
Alarm.delay(250);
servo.write(250);
Alarm.delay(250);
servo.write(0);
Alarm.delay(250);
servo.write(250);
Alarm.delay(250);
servo.write(0);
Alarm.delay(250);
servo.write(250);
Alarm.delay(250);
servo.write(0);
Alarm.delay(250);
servo.write(250);
Alarm.delay(250);
}
void digitalClockDisplay() {
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
void printDigits(int digits) {
Serial.print(":");
if (digits < 10)
Serial.print('0');
Serial.print(digits);
}