Frankly, I would use an interrupt to read the button presses.

For denouncing a button I would simply use a capacitor/resistor circuit: https://electronics.stackexchange.co...ounce-a-button If the input pin is low by default, it's even possible use a single 0.1uF capacitor to debounce the button.