/* 21/07/2021 forLoopv4 Purpose, nest "for loops" and "if else" */ //An int is an integer, a Number, any value between -32,768 and 32,767 int q; int w; void setup() { // Serial.begin(9600) starts serial communication. 9600bps bits per second = 1200 characters per second Serial.begin(9600); //Send script name Serial.println("forLoopv4..."); //this will print a blank line Serial.println(" "); } void loop() { //Nested for loops and if Serial.println("Nested for and if"); //q starts with a value of Zero, the loop continues while q smaller than 20 for (q = 0; q < 20; q++) { if (q == 5) { for (w = 10; w > -1; w--) { //print the value of q to the serial monitor Serial.print("q: "); Serial.print(q); Serial.print(" w: "); Serial.println(w); //delay within the for loop delay(100); } } else { Serial.print("q: "); Serial.println(q); } } //delay outside the for loop delay(1000); }