You still doing something like this:
DS3231 rtc(SDA, SCL);
in your new code (didn't see it in what you posted)
if so, and if using the arduino uno, then it seems that the library would set SCL to output, yet your reading it with:
valh = analogRead(5);
Not sure, but maybe that has "something" to do with a problem?
I'm sorry. I really am not a native speaker of english. I am not sure I understand what you mean. The owner of this (new) code, which is in my main post above, meant this code for arduino nano. But I don't know if that has to do with anything.
Additionally, like I said I am not very knowledgeable about electronics. So, please don't be sarcastic.
I tried some troubleshooting on my own and removed the cables going to A2, A1 (arduino) and the problem seems to be gone. So, it is definitately related to buttons.
do you think I should change it to analog read instead of digital read?
or perhaps, use valm<800 equation instead of valm==HIGH??