Hi together,
the idea of my first "program" is, that I'm iterating and everytime when the iterator variable has a "2" as a digit the ledPin is lightning for 5 seconds.
And a second iterator(waiter) is counting down, everytime, when the ledPin should light.
The Problem is that the if-case is only functioning with the number two.
After two the programm never comes back into the if-case and I don't understand why.
Could anyone help and I know that it is maybe a bloody noob question, because I am one.
int ledPin = 13;
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
Serial.println("MyFirstOwnArduinoProject");
Serial.println();
}
void loop()
{
int iterator = 0;
int fromLength = 0;
while(true){
String testIterator = String(iterator);
int toLength = String(iterator).length();
Serial.print("testIterator: " );
Serial.println(testIterator);
Serial.print("toLength :" );
Serial.println(toLength );
Serial.print("iterator: " );
Serial.println(iterator);
if(testIterator.substring(fromLength).equals("2") )
{
Serial.println("LIGHTNING++++++++++");
digitalWrite(ledPin, HIGH);
delay(5000);
digitalWrite(ledPin, LOW);
delay(1000);
int test0 = 0;
int sek = 2000;
while(sek !=test0)
{
sek--;
Serial.println(sek);
}
}
iterator++;
continue;
}
}