This is a debounced version of DigitalIn for Mechanical Switches. It is simplistic, and should be easy to use.

Dependents:   PID_ENCODER

Committer:
mr63
Date:
Fri Aug 16 17:49:32 2013 +0000
Revision:
0:323110faffe5
This is a Debounced version of DigitalIn

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mr63 0:323110faffe5 1 #include "mbed.h"
mr63 0:323110faffe5 2
mr63 0:323110faffe5 3 class DebouncedIn {
mr63 0:323110faffe5 4 public:
mr63 0:323110faffe5 5 DebouncedIn(PinName pin);
mr63 0:323110faffe5 6 bool get();
mr63 0:323110faffe5 7 void CheckState();
mr63 0:323110faffe5 8 bool get_pin();
mr63 0:323110faffe5 9
mr63 0:323110faffe5 10 private :
mr63 0:323110faffe5 11 // objects
mr63 0:323110faffe5 12 DigitalIn _pin;
mr63 0:323110faffe5 13 Ticker _poll;
mr63 0:323110faffe5 14
mr63 0:323110faffe5 15 };
mr63 0:323110faffe5 16
mr63 0:323110faffe5 17
mr63 0:323110faffe5 18