After starting the automatic mode, I cant switch it off.

Thank you cattledog! That is probably my problem indeed. I will try using the millis().

I am using pullups for the switches indeed :wink: