"3 value" boolean

For my project i have to be able to switch from °C to °F to the value of my alarm. The value of those 3 can be printed on my 7 segment displays that works perfectly. I have a button which changes value (0,1,2) when pressed. now the problem is that some time after the change of the value will still work but the it will only give the value of °C and alarm when pressing the button. And if i wait 20seconds more, the °F will be unblocked.
It is very strange because at the start it works perfectly, later not and even later it works again...

The code i use to switch between the 3 states:


code as an image is useless... can't copy..

do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including code tags and necessary documentation for your ask).

how do you deal with bouncing?

Well I guess a button handler, including debouncing, and a FSM could help.
Have a nice day and enjoy coding in C++.
Don´t forget to post your sketch in code tags.

Hello paulpaulson,
Could you tell me more about your idea?
I'm a beginner in this domain so i don't really understand..

You store millis in an int, which is probably 2 bytes so you probably have it change sign every minute or so

ooh so in what should i store it?

unsigned long millis() - Arduino Reference

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.