Use buttons to change values

I'm having problem to use button to change a certain values, variables. I want to have a button to change the value (by adding 10 to it everytime someone push the button) and a button to validate their choice (push_button3). The user can change the value as long as possible. My code looks like this but it doesn't seem to work yet, so any help is appreciated, thanks in advance:

const int pushButton = 2 ;
const int pushButton1 = 3 ;
const int pushButton3 = 5 ;

int celsius_infu = 50 ;

int i = 0;

void setup() {
  // put your setup code here, to run once:
pinMode(pushButton , INPUT);
pinMode(pushButton1 , INPUT);

pinMode(pushButton3 , INPUT);
Serial.begin (9600);

}

void loop() {
  int button_on = digitalRead(pushButton);
  int button_on1 = digitalRead(pushButton1);

  int button_on3 = digitalRead(pushButton3);

 if (button_on == HIGH ) {
      Serial.print("Enter temperature");
      Serial.print(celsius_infu);
      while (i == 0){
      if (button_on1 == HIGH ) {
      
         celsius_infu = celsius_infu + 10 ;
         
         if (celsius_infu=100){
          celsius_infu=50 ;
         }
     Serial.print(celsius_infu);
      if (button_on3 == HIGH) {
        i = 1 ;
      }

That cannot be all your code? You should use "INPUT_PULLUP" as pin mode for the buttons and test them for being "LOW" and you should "debounce" the buttons.

You code is waiting for the first button (button_on) to be pressed. After that it enters a while loop where "button_on1" and "button_on3" is tested for changes. But those two last values does not change in the while loop and that is why it does not work :slight_smile:

Tip: write a sketch which handles just one button and prints the text "button pressed" to the serial monitor.
That way you will see the need for button debouncing and can easily expand on that to solve your problem.

if (celsius_infu=100)

You should check this is doing what you want.

Also you need to consider whether the count should be incremented while the button is pressed (as now) or whether it would be better to increment it when it becomes pressed. See the StateChangeDetection example in the IDE.