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.
Diff: SalinitySensor.cpp
- Revision:
- 0:ad9362f18797
- Child:
- 1:f448c12d2c5b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SalinitySensor.cpp Thu Jun 02 17:53:02 2016 +0000
@@ -0,0 +1,41 @@
+/*
+* G3: WATERPLAY
+*/
+
+#include "SalinitySensor.h"
+#include "mbed.h"
+
+SalinitySensor::SalinitySensor(
+ PinName pin,
+ double const_voltage,
+ double const_converter,
+ double const_multiplier
+):
+ _analog_in(pin),
+ _const_voltage(const_voltage),
+ _const_converter(const_converter),
+ _const_multiplier(const_multiplier)
+{
+ read();
+}
+
+double SalinitySensor::read()
+{
+ _voltage = _analog_in.read();
+
+ return(_voltage);
+}
+
+double SalinitySensor::getVoltage()
+{
+ double retVal = _voltage * _const_voltage * _const_converter;
+
+ return(retVal);
+}
+
+double SalinitySensor::getSalinity()
+{
+ double retVal = getVoltage() * _const_multiplier;
+
+ return(retVal);
+}