a library to read sonar values with the MaxbotixLV sonar range sensors..

Committer:
kaushalpkk
Date:
Fri Jul 15 14:19:14 2011 +0000
Revision:
0:b99b1e0e3290
works fine with analog input.. i2c and uart will be updated

Who changed what in which revision?

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