
the MaxbotixLV sonar sensor interface software for analog. i2c and pwm will be added later.
Diff: MaxbotixLV.cpp
- Revision:
- 0:2c68f41f803d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MaxbotixLV.cpp Thu Jul 14 23:44:15 2011 +0000 @@ -0,0 +1,29 @@ +#include "mbed.h" +#include "MaxbotixLV.h" + +MaxbotixLV::MaxbotixLV(PinName analogIN): + _analogIn(analogIN) { + _voltIn = 3.300; + _scaler = 0.0098; +} + +void MaxbotixLV::setVoltage(float voltIn) { + _voltIn = (voltIn); +} + +void MaxbotixLV::setScale(float scaler) { + _scaler = (scaler); +} + +float MaxbotixLV::getInches() { + + float reading = _analogIn.read(); + float Avolts = reading * _voltIn; + return (Avolts / _scaler); +} + +float MaxbotixLV::getAnalog() { + return _analogIn.read(); +} + +