the MaxbotixLV sonar sensor interface software for analog. i2c and pwm will be added later.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MaxbotixLV.cpp Source File

MaxbotixLV.cpp

00001 #include "mbed.h"
00002 #include "MaxbotixLV.h"
00003 
00004 MaxbotixLV::MaxbotixLV(PinName analogIN):
00005         _analogIn(analogIN) {
00006     _voltIn = 3.300;
00007     _scaler = 0.0098;
00008 }
00009 
00010 void MaxbotixLV::setVoltage(float voltIn) {
00011     _voltIn = (voltIn);
00012 }
00013 
00014 void MaxbotixLV::setScale(float scaler) {
00015     _scaler = (scaler);
00016 }
00017 
00018 float MaxbotixLV::getInches() {
00019 
00020     float reading = _analogIn.read();
00021     float Avolts = reading * _voltIn;
00022     return (Avolts / _scaler);
00023 }
00024 
00025 float MaxbotixLV::getAnalog() {
00026     return _analogIn.read();
00027 }
00028 
00029