That kind of mostly uncommented code does not help the newbies.
Please add more to this
// Have we completed the interval?
char timeout(long *marker, long interval) {
if (millis() - *marker >= interval) {
*marker += interval;
return true;
}
else return false;
}
and this
if (timeout(&count1, 500)) {