User Tools

Site Tools


start

Good stuff to follow.

Millis not Delay

unsigned long eventInterval;
unsigned long previousTime;
void setup()
{
    eventInterval=5000; // 5 seconds
    previousTime=millis();
}
void loop() {
unsigned long currentTime = millis();

  /* This is the event */
  if (currentTime - previousTime >= eventInterval) {
    /* Event code */
    Serial.println("Timeout");
    
   /* Update the timing for the next time around */
    previousTime = currentTime;
  }
}
start.txt · Last modified: 2022/04/19 14:06 by admin