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

Dependencies:   mbed

Committer:
kaushalpkk
Date:
Thu Jul 14 23:44:15 2011 +0000
Revision:
0:2c68f41f803d
Initial release works on the analog outputs from the sensor..
i2c and PWM will be added soon.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kaushalpkk 0:2c68f41f803d 1 #include "mbed.h"
kaushalpkk 0:2c68f41f803d 2 #include "MaxbotixLV.h"
kaushalpkk 0:2c68f41f803d 3
kaushalpkk 0:2c68f41f803d 4 MaxbotixLV::MaxbotixLV(PinName analogIN):
kaushalpkk 0:2c68f41f803d 5 _analogIn(analogIN) {
kaushalpkk 0:2c68f41f803d 6 _voltIn = 3.300;
kaushalpkk 0:2c68f41f803d 7 _scaler = 0.0098;
kaushalpkk 0:2c68f41f803d 8 }
kaushalpkk 0:2c68f41f803d 9
kaushalpkk 0:2c68f41f803d 10 void MaxbotixLV::setVoltage(float voltIn) {
kaushalpkk 0:2c68f41f803d 11 _voltIn = (voltIn);
kaushalpkk 0:2c68f41f803d 12 }
kaushalpkk 0:2c68f41f803d 13
kaushalpkk 0:2c68f41f803d 14 void MaxbotixLV::setScale(float scaler) {
kaushalpkk 0:2c68f41f803d 15 _scaler = (scaler);
kaushalpkk 0:2c68f41f803d 16 }
kaushalpkk 0:2c68f41f803d 17
kaushalpkk 0:2c68f41f803d 18 float MaxbotixLV::getInches() {
kaushalpkk 0:2c68f41f803d 19
kaushalpkk 0:2c68f41f803d 20 float reading = _analogIn.read();
kaushalpkk 0:2c68f41f803d 21 float Avolts = reading * _voltIn;
kaushalpkk 0:2c68f41f803d 22 return (Avolts / _scaler);
kaushalpkk 0:2c68f41f803d 23 }
kaushalpkk 0:2c68f41f803d 24
kaushalpkk 0:2c68f41f803d 25 float MaxbotixLV::getAnalog() {
kaushalpkk 0:2c68f41f803d 26 return _analogIn.read();
kaushalpkk 0:2c68f41f803d 27 }
kaushalpkk 0:2c68f41f803d 28
kaushalpkk 0:2c68f41f803d 29