Skip to main content
added 67 characters in body
Source Link
Andrew
  • 7k
  • 20
  • 25

What do youTwo issues I can see? A single press of. Firstly when setting the button results in k increasing bydisplay to show a lot more than 1?2 you don't first clear the display so all of the segments that were lit remain lit.

MySecondly my guess is that you are seeing switch contact bouncing issues. When a switch or button closes the contacts touch, bounce apart, touch again, bounce apart etc... this can go on for several milliseconds and will look like lots of very fast button presses to the software.

The techniques to avoid this are known as debouncing, you can either implement them in hardware (a low pass filter on the input pin) or software (wait for the value on the input to remain stable for a fixed length of time) or a mixture of both.

For details on how to implement this sort of thing see google or search here for debouncing.

What do you see? A single press of the button results in k increasing by a lot more than 1?

My guess is that you are seeing switch contact bouncing issues. When a switch or button closes the contacts touch, bounce apart, touch again, bounce apart etc... this can go on for several milliseconds and will look like lots of very fast button presses to the software.

The techniques to avoid this are known as debouncing, you can either implement them in hardware (a low pass filter on the input pin) or software (wait for the value on the input to remain stable for a fixed length of time) or a mixture of both.

For details on how to implement this sort of thing see google or search here for debouncing.

Two issues I can see. Firstly when setting the display to show a 2 you don't first clear the display so all of the segments that were lit remain lit.

Secondly my guess is that you are seeing switch contact bouncing issues. When a switch or button closes the contacts touch, bounce apart, touch again, bounce apart etc... this can go on for several milliseconds and will look like lots of very fast button presses to the software.

The techniques to avoid this are known as debouncing, you can either implement them in hardware (a low pass filter on the input pin) or software (wait for the value on the input to remain stable for a fixed length of time) or a mixture of both.

For details on how to implement this sort of thing see google or search here for debouncing.

Source Link
Andrew
  • 7k
  • 20
  • 25

What do you see? A single press of the button results in k increasing by a lot more than 1?

My guess is that you are seeing switch contact bouncing issues. When a switch or button closes the contacts touch, bounce apart, touch again, bounce apart etc... this can go on for several milliseconds and will look like lots of very fast button presses to the software.

The techniques to avoid this are known as debouncing, you can either implement them in hardware (a low pass filter on the input pin) or software (wait for the value on the input to remain stable for a fixed length of time) or a mixture of both.

For details on how to implement this sort of thing see google or search here for debouncing.