Arduino-Scheduler
Portable Collaborative Multi-Tasking Scheduler for Arduino
SchedulerAlarmClock.ino
Go to the documentation of this file.
1 
22 #include <Scheduler.h>
23 
24 #include "Clock.h"
25 #include "Alarm.h"
26 
27 // Check for SparkFun SAMD21 Breakout
28 #if defined(ARDUINO_ARCH_SAMD) && (USB_PID == 0x8D21)
29 #define Serial SerialUSB
30 #endif
31 
32 void setup()
33 {
34  Serial.begin(57600);
35  while (!Serial);
36  Serial.println(F("SchedulerAlarmClock: started"));
37 
38  // Initiate tasks
41 
42  // Set alarm time
43  Alarm::time = 15;
44 }
45 
46 void loop()
47 {
48  unsigned long seconds = Clock::seconds;
49  unsigned long minutes = seconds / 60;
50  unsigned long hours = minutes / 60;
51  Serial.print(millis());
52  Serial.print(':');
53  Serial.print(hours);
54  Serial.print(':');
55  Serial.print(minutes % 60);
56  Serial.print(':');
57  Serial.println(seconds % 60);
58  await(seconds != Clock::seconds);
59 }
60 
void loop()
Definition: Alarm.h:35
void loop()
Definition: Clock.h:33
void setup()
Definition: Clock.h:29
#define await(cond)
Definition: Scheduler.h:162
void setup()
Definition: Alarm.h:31
volatile unsigned long seconds
Definition: Clock.h:27
SchedulerClass Scheduler
Definition: Scheduler.cpp:53
void setup()
static bool start(func_t taskSetup, func_t taskLoop, size_t stackSize=DEFAULT_STACK_SIZE)
Definition: Scheduler.cpp:76
void loop()
unsigned long time
Definition: Alarm.h:29