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.
Fork of analoghalls5_5 by
Diff: voltagesensors.cpp
- Revision:
- 0:54cf32d35f4d
- Child:
- 1:1f58bdcf2956
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/voltagesensors.cpp	Sun Mar 01 06:16:01 2015 +0000
@@ -0,0 +1,15 @@
+#include "includes.h"
+#include "classes.h"
+
+AnalogVoltageSensor::AnalogVoltageSensor(PinName pin, float scale) {
+    _in = new AnalogIn(pin);
+    _scale = scale;
+}
+
+void AnalogVoltageSensor::Zero() {
+    _zero_level = (float) *_in;
+}
+
+float AnalogVoltageSensor::GetVoltage() {
+    return ((float) *_in - _zero_level) * 3.3f / _scale;
+}
\ No newline at end of file
    