|
- #include <TimerThree.h>
-
-
-
-
-
-
- const int led = LED_BUILTIN;
-
- void setup(void)
- {
- pinMode(led, OUTPUT);
- Timer3.initialize(150000);
- Timer3.attachInterrupt(blinkLED);
- Serial.begin(9600);
- }
-
-
-
-
- int ledState = LOW;
- volatile unsigned long blinkCount = 0;
-
- void blinkLED(void)
- {
- if (ledState == LOW) {
- ledState = HIGH;
- blinkCount = blinkCount + 1;
- } else {
- ledState = LOW;
- }
- digitalWrite(led, ledState);
- }
-
-
-
-
- void loop(void)
- {
- unsigned long blinkCopy;
-
-
-
-
-
-
- noInterrupts();
- blinkCopy = blinkCount;
- interrupts();
-
- Serial.print("blinkCount = ");
- Serial.println(blinkCopy);
- delay(100);
- }
|