I've attached below some VERY simple code that should count the number of times a loop is run
int LoopCounter = 0;
void setup() {
Serial.begin(57600);
delay(1000);
Serial.println("resetting");
}
void loop() {
Serial.print("Loop counter = "); //for debugging
Serial.println(LoopCounter); //for debugging
delay(1000);
if (LoopCounter = 10){
Serial.println("I should only see this sentence once!");
LoopCounter = LoopCounter + 1;
}
else {
LoopCounter = LoopCounter + 1;
}
}
It doesn't, and I can't figure out why. I simplified the code and intend to put some interesting stuff where the "sentence" is once this starts running as desired.
This is what my com port displays:
resetting
Loop counter = 0
I should only see this sentence once!
Loop counter = 11
I should only see this sentence once!
Loop counter = 11
I should only see this sentence once!
Loop counter = 11
Ideally the code counts up from zero by ones.
What am I missing?