Use software debounce

- Add debounce
- Use more variables