Apprentice coder

An easy way to debounce your input is to use a short delay - twenty milliseconds would be enough. Put it in the body of the if that executes if the state of the button has changed. Generally, using delay is frowned upon because it tends to make your program unresponsive. Short delays like this for debouncing won't be noticeable by the user though.