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