Chat freely about anything...

User avatar
By Trey
#52856 Can anyone help me understand how to implement Millis for timing here?

Code: Select all
bool isReady = false;
void loop()
{
       if(isReady == false)
      {
            //No data just wait
      }
      else
      {
           myMethod();
      }
}


unsigned long previousMillis = 0;
void myMethod()
{
 int counter = 0;
  for(int i = 0; i < 1024; i ++)
  {
    //other operations
   
    if(counter == 64)
    {
        unsigned long currentMillis = millis();
        if (currentMillis - previousMillis >= interval) {
            previousMillis += interval;
            //Do Work HERE
            counter = 0;
        }     
    }
    else{counter ++};

   }
}