Hi guys
I've written a program where I want the loop section to repeat a fixed number of times then exit the loop and confirm a message on the LCD once it exits. I've obviously messed up somewhere as the count stipulate in the 'for' argument increments to its limit but then just restarts the loop and begins counting from zero again, ad-infinitum.
Could someone point out where I've gone wrong with this please, if possible?
Thanks very much!
So what I was wanting is the "end loops" message after the count hits 5 and the loop stops, followed by the "finished" message. I get the end loop message but then the whole loop and count starts over.
#include "LiquidCrystal.h"
LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );byte ledPin = 13;
void setup()
{
Serial.begin(9600); // start serial output
Serial.println("Starting");lcd.begin(16, 2); // start the lcd object - specifies the size of it. Must have this!
lcd.setCursor(0,0);
lcd.print("Starting");digitalWrite(ledPin, LOW);
delay(2000);pinMode(ledPin, OUTPUT); // Set the LED pin as an output
}void loop()
{
// set up how many loops:
for (int count=0; count <= 5; count++)
{
// begin loop ******************************
lcd.setCursor(0, 1); //move to second line
lcd.print("Test");lcd.setCursor(0,1);
lcd.print(" "); // Blank
lcd.setCursor(0,1);
lcd.print("Move..."); // Blank
delay(500);Serial.println("Wait...");
Serial.println(500);
Serial.println("Count...");
Serial.println(count);lcd.print("Wait...");
lcd.setCursor(8,1);
lcd.print(500);
lcd.print("Count = ");
lcd.setCursor(9,1);
lcd.print(count);
// end loop ********************
}
Serial.println("End loops");
lcd.print("End loops");
}void endmsg() { Serial.println("All finished");
lcd.print("All finished"); }