Adjusting setpoints via pushbuttons

Hi forum.

I have programmed a controller on a uno board, it activates relays for an actuator based on temperature readings from a DHT21/am2301, i have it connected to a 20x4 lcd display

I got the function and display working showing temperature, humidity, heat index and the state of relays.

My problem is i would like to be able to adjust the setpoints at which my relays is being activated by pressing a few pushbuttons.

I got 4 setpoints and i was thinking i could do it with 3 buttons.

  1. Pushbutton activates edit mode and toggles between setpoints.

  2. Pushbutton is adjusting the value up.

  3. Pushbutton is adjusting the value down.

I have been searching for a tutorial or some examples i can borrow the princips from.

Hope somebody can help with an example of how to do. :slight_smile:

what did you allready came up with?

poeple are more willing to help if you first show u your try.

I suggest you hold down one button and use the second to toggle between selection screens.
When you are at the desired screen release the first button and use the second and third to increase or decrease the setting.
When you are finished hold the first button and press the third button to signify that you are finished with settings and to save the values to the EEPROM.

...R

Hi Robin2.

what you are talking about is what i am looking for, i would just like to se the code in practical use, i have been searching in forum, playground and google, but i haven't found anything i could study and convert for my project.

i have had some other IT issues, but i came up with another solution, pushbutton counters and a lot of if if to modify thresholds.

// read the pushbutton input pin:
buttonState1 = digitalRead(buttonPin1);
// compare the buttonState to its previous state
if (buttonState1 != lastButtonState1) {
// if the state has changed, increment the counter
if (buttonState1 == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter1++;
Serial.print("number of button1 pushes: ");
Serial.println(buttonPushCounter1);
}
}
lastButtonState1 = buttonState1;

// read the pushbutton input pin:
buttonState2 = digitalRead(buttonPin2);
// compare the buttonState to its previous state
if (buttonState2 != lastButtonState2) {
// if the state has changed, increment the counter
if (buttonState2 == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter2++;
Serial.print("number of button2 pushes: ");
Serial.println(buttonPushCounter2);
}
}
lastButtonState2 = buttonState2;

// read the pushbutton input pin:
buttonState3 = digitalRead(buttonPin3);
// compare the buttonState to its previous state
if (buttonState3 != lastButtonState3) {
// if the state has changed, increment the counter
if (buttonState3 == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter3++;
Serial.print("number of button3 pushes: ");
Serial.println(buttonPushCounter3);
}
}
lastButtonState3 = buttonState3;

// function for setting threshold 1
if (buttonPushCounter1 == 1) {
if (buttonPushCounter2 == 1){
threshold1= threshold1 + 1;
}}
if (buttonPushCounter1 == 1) {
if (buttonPushCounter3 == 1){
threshold1 = threshold1 - 1;
}}
// function for setting threshold 2
if (buttonPushCounter1 == 2) {
if (buttonPushCounter2 == 1){
threshold2= threshold2 + 1;
}}
if (buttonPushCounter1 == 2) {
if (buttonPushCounter3 == 1){
threshold2 = threshold2 - 1;
}}
// function for setting threshold 3
if (buttonPushCounter1 == 3) {
if (buttonPushCounter2 == 1){
threshold3= threshold3 + 1;
}}
if (buttonPushCounter1 == 3) {
if (buttonPushCounter3 == 1){
threshold3 = threshold3 - 1;
}}
// function for setting threshold 4
if (buttonPushCounter1 == 4) {
if (buttonPushCounter2 == 1){
threshold4= threshold4 + 1;
}}
if (buttonPushCounter1 == 4) {
if (buttonPushCounter3 == 1){
threshold4 = threshold4 - 1;
}}

if (buttonPushCounter1 >= 5){
buttonPushCounter1 = 0;
}
if (buttonPushCounter2 == 1){
buttonPushCounter2=0;
}
if (buttonPushCounter3 == 1){
buttonPushCounter3=0;
}

it is not as fancy but it can do the job, the downsides is that values isn't stored in EEPROM, and i can't see on display what i am doing, and there is a lot of code.

finally i got some really helpfull exampless on LCD menus and saving values to EEPROM on another forum, so now i got something to study.

BR Søren.