Skip to content

Commit a0ac703

Browse files
author
JChristensen
committed
Added "blink2" example
1 parent 6e5f721 commit a0ac703

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

ReadMe.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ Updated keywords.txt file to include all functions.
1919
o Replaced a bunch of magic numbers in <Timer.cpp> by the above constants
2020
o Added several comments
2121
o Added Timer::pulseImmediate(). pulseImmediate sets the pin to the specified value for the given
22-
duration. After the duration, the pin is set to !value.
22+
duration. After the duration, the pin is set to !value.
23+
24+
1.2 by Jack Christensen
25+
o Added "blink2" example illustrating flashing two LEDs at different rates.

examples/blink2/blink2.ino

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//Flash two LEDs at different rates using Simon Monk's Timer library
2+
//http://www.doctormonk.com/2012/01/arduino-timer-library.html
3+
//
4+
//Jack Christensen 30Sep2013
5+
//
6+
//Beerware license: Free for any and all purposes, but if you find it
7+
//useful AND we actually meet someday, you can buy me a beer!
8+
9+
#include "Timer.h" //http://github.com/JChristensen/Timer
10+
11+
const int LED1 = 8; //connect one LED to this pin (with appropriate current-limiting resistor of course)
12+
const int LED2 = 9; //connect another LED to this pin (don't forget the resistor)
13+
const unsigned long PERIOD1 = 1000; //one second
14+
const unsigned long PERIOD2 = 10000; //ten seconds
15+
Timer t; //instantiate the timer object
16+
17+
void setup(void)
18+
{
19+
pinMode(LED1, OUTPUT);
20+
pinMode(LED2, OUTPUT);
21+
t.oscillate(LED1, PERIOD1, HIGH);
22+
t.oscillate(LED2, PERIOD2, HIGH);
23+
}
24+
25+
void loop(void)
26+
{
27+
t.update();
28+
}
29+

0 commit comments

Comments
 (0)