First of all, here is the code:
void DS1302Startup(bool changingTime){
Rtc.Begin();
if(changingTime == true){
while(digitalRead(8) == LOW){
Serial.println("test");
}
Serial.println("test2");
bool hm;
char HMS;
while(1){
n = digitalRead(encoder0PinA);
if ((encoder0PinALast == HIGH) && (n == LOW)) {
if (digitalRead(encoder0PinB) == HIGH) {
if(hm == true){
encoder0Pos2--;
encoder0Pos = max(encoder0Pos2,0);
encoder0Pos2 = encoder0Pos;
}
else{
encoder1Pos2--;
encoder1Pos = min(encoder1Pos2,0);
encoder1Pos2 = encoder1Pos;
}
} else {
if(hm == true){
encoder0Pos2++;
encoder0Pos = min(encoder0Pos2,24);
encoder0Pos2 = encoder0Pos;
}
else{
encoder1Pos2++;
encoder1Pos = min(encoder1Pos2,59);
encoder1Pos2 = encoder1Pos;
}
}
}
encoder0PinALast = n;
HMS = char(sprintf(encoder0Pos, 2));
HMS += ":";
HMS += char(sprintf(encoder1Pos, 2));
HMS += ":";
HMS += "00";
Serial.println(HMS);
if(digitalRead(8) == LOW){
milli = millis();
while(digitalRead(8) == LOW){
}
if(millis() - milli <10){
}
else if(millis() - milli > 10 && millis() - milli < 2000){
hm = !hm;
}
else if(millis() - milli > 2000){
HMS = char(encoder0Pos);
HMS += ":";
HMS += char(encoder1Pos);
HMS += ":";
HMS += "00";
break;
}
}
FastLED.clear();
displayTime(String(HMS), 0);
FastLED.show();
}
RtcDateTime compiled = RtcDateTime("03 31 2020", char(HMS));
Rtc.SetDateTime(compiled);
}
}
That is, as you can see not the whole code. I'll put the file into the attechments because otherwise I would have to paste the whole 970 lines in here.
So, the Problem is that, if I start the program the bool changingTime equals true. Then the code starts the rtc clock and checks if changeTime equals true. If it equals true, it waits for the pushbutton to release. For that, I use a while loop that waits for the pushbutton to be released. As you can see, I've already putten Serial.println("test") into the while loop. The code still works fine and prints out test in the serial monitor as long as i hold down the pushbutton. After I stop pressing the pushbutton, Serial.println("test2") is not executed. But before i made some changes to the code, all worked fine. Sadly, I can't remember the changes.
BinarySecs.ino (261 Bytes)
DemoReel100_Uhr_Verstellen.ino (5.39 KB)
displayTime.ino (904 Bytes)
DS1302.ino (570 Bytes)
DS1302Startup.ino (2.06 KB)
NumberPatterns.ino (4.05 KB)
setNumber.ino (12.7 KB)