how to distinguish one press with hold down key

hi guys,

There is a push button, I read with a digital pin ,

e.g. once this button is pressed , I want pin number D9 to be HIGH

If I hold this button long , I want D9 pin will never be HIGH, pin D10 will be HIGH

I couldn't fix this problem, how should I solve this problem

Thank you very much in advance

State change detection. Look it up

Detect when button was pressed and when it was released. Then it is a simple matter to record the time of each and check if the difference is greater than your longPress interval

The code in this link illustrates how do deal with different button presses.

...R

The button will behave differently because you cannot immediately act on the button press. You have now to wait until a timeout has expired, or the button being released, before determining whether it was a long press or a short press.
Set a timer when the button is pressed and continuously test for the expiry of the timeout. If the button is released before the expiry, it was a short press, otherwise a long press.

See button long press and short press

IoT_hobbyist:
See button long press and short press

yes, this works the way I want