hi
i have some problem in my MsTimer code
#include <MsTimer2.h>
int ex_time = 0;
int now_time = 0;
void setup() {
Serial.begin(9600);
MsTimer2::set(100, timer);
MsTimer2::start();
}
void loop() {
ex_time = now_time;
while((now_time - ex_time) <= 70) {
}
Serial.println("HI");
}
void timer(void) {
//Serial.println(now_time);
//Serial.println(ex_time);
now_time++;
}
this code does not print HI,
#include <MsTimer2.h>
int ex_time = 0;
int now_time = 0;
void setup() {
Serial.begin(9600);
MsTimer2::set(100, timer);
MsTimer2::start();
}
void loop() {
ex_time = now_time;
while((now_time - ex_time) <= 70) {
Serial.print("");
}
Serial.println("HI");
}
void timer(void) {
//Serial.println(now_time);
//Serial.println(ex_time);
now_time++;
}
But this code prints the HI!!
Why doesn't the first code work?
Both the first and second codes confirm that the timer is working.
I think doesn't work loop or while in first code, but i'm not sure.
Can you tell me why this is happening?
Thanks