forked from GadgetFactory/DesignLab_Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimer_Example.ino
More file actions
54 lines (38 loc) · 857 Bytes
/
Timer_Example.ino
File metadata and controls
54 lines (38 loc) · 857 Bytes
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
/*
Gadget Factory
Zpuino 2.0 Timer Example
To learn more about using DesignLab please visit http://learn.gadgetfactory.net
Tutorials:
Related library documentation:
Hardware:
Special Notes:
created 2015
by Jack Gassett
http://www.gadgetfactory.net
This example code is in the public domain.
*/
#define circuit ZPUino_Vanilla
#include <Timer.h>
int led = 13;
int ledVal = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(led, OUTPUT);
//Setup timer that will generate an interrupt at 1hz
Timers.begin();
int r = Timers.periodicHz(1, timer, 0, 1);
if (r<0) {
Serial.println("Fatal error!");
}
}
bool timer(void*)
{
//1Hz Timer
Serial.println("In Timer");
ledVal = ~ledVal;
digitalWrite(led, ledVal);
return true;
}
void loop() {
}