read LDR sensor

Dependents:   Mytemperature_Motion

LDR_sensor.h

Committer:
sharifdeens
Date:
2019-04-21
Revision:
0:b6b6c41a37e6

File content as of revision 0:b6b6c41a37e6:

#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();
}