Ensured that button clicks are only registered on rising edges by keeping track of previous button states.