read LDR sensor
Dependents: Mytemperature_Motion
Diff: LDR_sensor.h
- Revision:
- 0:b6b6c41a37e6
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(); +}