(Maybe it completely unrelated, but my analog reading on A0 is oscillating, very unstable)
I have the commands packed on a function
unsigned long t0 = 0;
const long dt = 1000;
void blinkNoD(int pin) {
unsigned long t = millis();
if(t - t0 >= dt) {
t0 = t;
led=!led;
digitalWrite(pin, led);
}
}
Since I already have delay in loop, and it really messed with the timing (not mention that maybe the analog reading instability have anything to do with it), I decided to modify the blink code, still without delay command.
unsigned long t0 = 0;It turned out that my analogRead instability is another problem, get to work on it, :)
const long dt = 1;
void blinkNoD(int pin) {
t0 += dt
if(t0 >= 4) {
t0 = 0;
led=!led;
digitalWrite(pin, led);
}
}
No comments:
Post a Comment