moisture
Dependents: Mytemperature_Motion
Revision 0:43662c8b01ce, committed 2019-04-21
- Comitter:
- sharifdeens
- Date:
- Sun Apr 21 03:29:08 2019 +0000
- Commit message:
- moisture sensor
Changed in this revision
moisture_sensor.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 43662c8b01ce moisture_sensor.h --- /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(); +}