Ecco il mio loop:
void loop() {
////////////////////////////////////////////////////////////
////////////////////CHANGE STATE////////////////////////////
////////////////////////////////////////////////////////////
// read the CHST input pin:
buttonState = digitalRead(StateChange);
// compare the Pin to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the radio has sent the call
stamp();
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
// Display time right on the upper line
lcd.setCursor(12, 0);
lcd.print(rtc.getTimeStr());
// Display date in the lower right corner
lcd.setCursor(10, 1);
lcd.print(rtc.getDateStr());
// Wait one second before repeating
delay(20);