timing management improvements
This commit is contained in:
parent
e0cb8e74ca
commit
ffdc4dc101
@ -11,7 +11,7 @@
|
|||||||
#define MEASUREPIN A3
|
#define MEASUREPIN A3
|
||||||
#define MOSFETPIN A2
|
#define MOSFETPIN A2
|
||||||
|
|
||||||
unsigned long oldtime = -1;
|
unsigned long oldtime = 0;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
@ -61,7 +61,8 @@ void loop() {
|
|||||||
Serial.print("Voltage: ");
|
Serial.print("Voltage: ");
|
||||||
Serial.println(voltage);
|
Serial.println(voltage);
|
||||||
|
|
||||||
int delaytime = INTERVALTIME * 1000 - ((micros() - oldtime) / 1000);
|
unsigned int delaytime = (micros() - oldtime) / 1000;
|
||||||
|
Serial.println(INTERVALTIME * 1000 - delaytime);
|
||||||
|
delay(INTERVALTIME * 1000 - delaytime);
|
||||||
oldtime = micros();
|
oldtime = micros();
|
||||||
delay(delaytime);
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user