How should the Also, do not press the switch software. But the 78 display out.

button_logic = digitalRead(buttonPin1);
   button_logic2 = digitalRead(buttonPin2);
  if((button_logic_pre == LOW)&&(button_logic == HIGH)){
    delay(10);
    button_logic = digitalRead(buttonPin1);
    if(button_logic == HIGH){
      Serial.print(78);

   
        }
  }
int button_logic = 0;
int button_logic_pre = 0;
const int buttonPin1 =  7;
void setup() {
  pinMode(buttonPin1,INPUT_PULLUP);
}

Was there a question with that code? OR is that supposed to be the question in the title? It makes no sense. Maybe you should try to be a little more verbose and explain in words what you are trying to do and how that compares with what is actually happening.

And post complete code. I can't tell from those three snippets how all of that fits together.

What's the question?

Seems to me that if button1 went from low to high, you wait 10ms and read it again. If it's still high, you want to show 78 on the monitor?

I was not hitting anything.

Showing 78 applications out before I hit. buttonPin1

How am I supposed to press before the show No. 78.

With INPUT_PULLUP an unpressed button is HIGH, goes LOW when pressed.

You initialise it as 0 which is LOW, but as soon as it reads it it goes HIGH since (I assume) it's unpressed. So the low to high transition in the if is satisfied. Then you read it again, still high, so it prints.

You probably need to swap the lows and highs in your thinking.

manor_royal:
With INPUT_PULLUP an unpressed button is HIGH, goes LOW when pressed.

You initialise it as 0 which is LOW, but as soon as it reads it it goes HIGH since (I assume) it’s unpressed. So the low to high transition in the if is satisfied. Then you read it again, still high, so it prints.

You probably need to swap the lows and highs in your thinking.

Let me set ?

int button_logic = 1;
int button_logic_pre = 1;
const int buttonPin1 =  7;[code]


[code]void setup() {
  pinMode(buttonPin1,INPUT);
}[code]

OK, but if you do that you'll need to add an external pull-down resistor with your button to make sure it reads low when it is not pressed.

The more common thing to do is to leave the internal pullup enabled and to wire the button so that it reads LOW when it is pressed.