/*
  ============================
   Selfmade For-Loop I
  ============================

   This is an example of a "selfmade" for-loop
   which is usually required where a a non-blocking
   loop is required

   First Edition 2023-04-02
   ec2021

   Simulation: https://wokwi.com/projects/360901842970872833
   Discussion: https://forum.arduino.cc/t/millis-instead-of-delay-and-loop-instead-of-for-loop/1110044

  Changed 2023-07-26

*/

void setup() {
   Serial.begin(115200);

   // Standard for-loop
   Serial.println("Standard for-loop");
   for (int i = 0; i < 10;i++){
     Serial.print(i);
     Serial.print("\t"); // prints tabs
   }
   Serial.println();
   Serial.println("Selfmade for-loop");
}

// Selfmade for-loop with the same result as the Standard for-loop coded in setup()

// The next line replaces the (int i = 0) in for (int i = 0; i < 10;i++)
 //                                               ---------
int i = 0;

void loop() {
   // This replaces the condition in  for (int i = 0; i < 10;i++)
   //                                                 ------
   if (i < 10) { 
     Serial.print(i);
     Serial.print("\t"); // prints tabs
     i++;
   }
}