Internet of Things, Arduino/Netduino: Counting the closure of a switch

Counting things and then storing them for later use in data analysis requires a bunch of things.  One of the main things is that the number of times a switch closes is an important data point for many categories of work:  manufacturing, retail, physical security and safety to name a few.

It seems simple, a switch closes and you count that as a 1 so that the variable switchclosure = switchclosure + 1; or does it?  Well in the physical world of mechanical things, magnetic fields, chemical interactions, a switch closure might be a number of things.  One of the things it might be is a “bounce”.  The switch could function in response to a physical movement of a rocker against a metallic contact that then connects to another metal plate.  Easy.  Oops, what about if the metal contacts touch and then bounce from the other surface breaking contact for a few milliseconds.  And then contact again, breaking contact, contact and so forth.  Those are all switch closures.  Let’s say there were 4 bounces on each switch closure that was counted as, wait for it…switch closures!

Do those count as switch closures?  Do they?  Well, they could, but in the instance in which I am writing this, they are 4 EXTRA switch closures.  Sometimes it’s only 2 extra and other times it is 5.  What do you do?

Just asking.  Any ideas?

Netduino Hint:

Arduino hint

  • image
Comments (0)

Skip to main content