PickyBiker
Well-known member
The attached sketch should print a number every second but on my Teensy 4.0 it is printing almost 2 times per second.
Can someone tell me what I am doing wrong?
Can someone tell me what I am doing wrong?
Code:
#include <TimerOne.h>
void setup()
{
Serial.begin(115200);
Timer1.initialize(100000); // .1 second timer
Timer1.attachInterrupt(ISR_Timer);
Timer1.start();
}
void loop()
{
}
/***************************************************************************************************************/
void ISR_Timer()
{
static int cnt = 0, cnt2 = 0;
cnt += 1;
if (cnt >= 10)
{
cnt = 0;
cnt2 += 1;
Serial.println(cnt2);
}
}