moisture
Dependents: Mytemperature_Motion
Diff: moisture_sensor.h
- Revision:
- 0:43662c8b01ce
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/moisture_sensor.h Sun Apr 21 03:29:08 2019 +0000 @@ -0,0 +1,35 @@ +#include "mbed.h" + +//Sensor new class for sensorA +class moisture_sensor + +{ +public: + + moisture_sensor(PinName pin); + moisture_sensor(); + operator float (); + float read(); +private: +//class sets up the AnalogIn pin + AnalogIn _pin; +}; + + +moisture_sensor::moisture_sensor(PinName pin) : _pin(pin) +{ +// _pin(pin) means pass pin to the AnalogIn constructor +} + +float moisture_sensor::read() + +{ +//read moisture sensor + return _pin.read(); +} + +moisture_sensor::operator float () +{ +//convert sensor reading to temperature in degrees C + return _pin.read(); +}