-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72afe04
commit f29ae85
Showing
2 changed files
with
52 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef BLINKER_H | ||
#define BLINKER_H | ||
|
||
#include "board.h" | ||
|
||
#include <Ticker.h> | ||
|
||
class Blinker : public Ticker | ||
{ | ||
public: | ||
Blinker(unsigned ms): | ||
Ticker() | ||
{ | ||
attach_ms(ms, callback, &state); | ||
} | ||
|
||
~Blinker() { | ||
// turn off the LED | ||
digitalWrite(PIN_LED1, HIGH); | ||
} | ||
|
||
private: | ||
int state = HIGH; | ||
|
||
static void callback(int *st) { | ||
digitalWrite(PIN_LED1, *st); | ||
*st ^= HIGH; | ||
} | ||
}; | ||
|
||
#endif // BLINKER_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters