So i'm trying to make it so that when the temp_up button is pressed the set temperature increases by 1, same for the temp_down button but it decrements by 1. I have got the buttons working however when I click the temp_up button once to increase the set temperature it does it repeatedly in a loop. The code itself is in the void loop which could be why however it should work with the if statements as i used the same type of code for the push-button to turn on LED which works.
Anyone got any ideas, i'm wanting to make it so that when the temp_up button is pressed it only increases once until i press it again rather than the set temperature repeatedly increasing. It's assuming the remote button is not unpressed. This problem also exists with the temp_down button.
Any help much appreciated.
Code: [Select]
if(results.value == temp_up)
{
set_temp++;
Serial.print("Set temperature increased by 1 Degree C to ");
Serial.println(set_temp);
}
else if (results.value == temp_down)
{
set_temp--;
Serial.print("Set temperature decreased by 1 Degree C to ");
Serial.println(set_temp);
}


Welcome to the Forum. Please read these two posts:
General Guidance and How to use the Forum and
Read this before posting a programming question ...
You may also find useful information that would answer your question here:
Useful links - check here for reference posts / tutorials
It is important to provide as much of the information that is needed to solve your problem as you can, in your first posts. The forum link above has guidelines for posting in a standard way that makes it easiest for people to provide you with useful answers. Making an effort to do this will greatly increase the number and quality of helpful responses that you get.
In this case, the problem is that you have posted code in an image instead of using code tags. The code tags make the code look
like this
when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don't do it, some of the character sequences in the code can be misinterpred by the forum code as italics or funny emoticons. The "Code: [Select]" feature allows someone to select the entire sketch so it can be easily copied and pasted into the IDE for testing.
Meanwhile, look at the State Change Detection example in the IDE example sketches.