read LDR sensor
Dependents: Mytemperature_Motion
Revision 0:b6b6c41a37e6, committed 2019-04-21
- Comitter:
- sharifdeens
- Date:
- Sun Apr 21 03:29:41 2019 +0000
- Commit message:
- ldr
Changed in this revision
LDR_sensor.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r b6b6c41a37e6 LDR_sensor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LDR_sensor.h Sun Apr 21 03:29:41 2019 +0000 @@ -0,0 +1,35 @@ +#include "mbed.h" + +//Sensor new class for sensorA +class LDR_sensor + +{ +public: + + LDR_sensor(PinName pin2); + LDR_sensor(); + operator float (); + float read(); +private: +//class sets up the AnalogIn pin + AnalogIn _pin2; +}; + + +LDR_sensor::LDR_sensor(PinName pin2) : _pin2(pin2) +{ +// _pin(pin) means pass pin to the AnalogIn constructor +} + +float LDR_sensor::read() + +{ +//read moisture sensor + return _pin2.read(); +} + +LDR_sensor::operator float () +{ +//convert sensor reading to temperature in degrees C + return _pin2.read(); +}