Analog-to-binary input with hysteresis
Dependents: Hysteresis LAB9_Hysteresis LAB18_StreetLight
Diff: HysteresisIn.h
- Revision:
- 0:fe43537bd3d6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HysteresisIn.h Fri Dec 20 19:21:57 2013 +0000 @@ -0,0 +1,26 @@ +// ==================================================== Dec 21 2013, kayeks == +// HysteresisIn.h +// =========================================================================== +// Analog to binary input class with hysteresis +// - For a simple Schmitt-Trigger substitute + +#ifndef HYSTERESIS_IN_H_ +#define HYSTERESIS_IN_H_ + +#include "mbed.h" + +class HysteresisIn { +private: + AnalogIn in; + float thresholdHighToLow; + float thresholdLowToHigh; + bool state; + +public: + HysteresisIn(PinName inputPin, float htl, float lth, bool initialState=0); + ~HysteresisIn(); + bool read(); + void write(bool newState); +}; + +#endif