Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Mytemperature_Motion
moisture_sensor.h
- Committer:
- sharifdeens
- Date:
- 2019-04-21
- Revision:
- 0:43662c8b01ce
File content as of revision 0:43662c8b01ce:
#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();
}