Help me debounce my buttons

My project has 2 buttons working a linear actuator. They are randomly pressing when i dont want them to. I think debouncing will fix it but i dont know where start with this code which i did not originally write.

Any pointers ? Any help is appreciated

My code
https://paste.ofcode.org/LXtrkq6eF5tebTp3DZRwGS

Use this library

hey are randomly pressing when i dont want them

debouncing, as the name suggests, is because of the contact bouncing against one another when making contact.

did you configure you inputs as INPUT_PULLUP or do you have pull-up/down resistors on your inputs?

gcjr:
debouncing, as the name suggests, is because of the contact bouncing against one another when making contact.

did you configure you inputs as INPUT_PULLUP or do you have pull-up/down resistors on your inputs?

There are no resistors in my circuit. I am using momentary push buttons

my code is

pinMode(2,INPUT_PULLUP); // Button input
pinMode(3,INPUT_PULLUP); // Button input

airflow:
There are no resistors in my circuit

my code is

pinMode(2,INPUT_PULLUP); // Button input
pinMode(3,INPUT_PULLUP); // Button input

You don't need to worry about any of that if you use the library.

OK i'll have a look

Power_Broker:
You don't need to worry about any of that if you use the library.

Except that you have to tell the library if you want it to use the internal pullup and, if you don't, whether the external resistor is a pull-up or pull-down resistor. :slight_smile: