Analog-to-binary input with hysteresis

Dependents:   Hysteresis LAB9_Hysteresis LAB18_StreetLight

HysteresisIn.h

Committer:
kayekss
Date:
2013-12-20
Revision:
0:fe43537bd3d6

File content as of revision 0:fe43537bd3d6:

// ==================================================== 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