hisyam fs / Mbed 2 deprecated Test_all

Dependencies:   mbed ADS1115 StepperMotor SRF05 TPA81new

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SharpIR.cpp Source File

SharpIR.cpp

00001 #include "SharpIR.h"
00002 
00003 SharpIR::SharpIR(PinName apin) : _ain(apin), _a(def_a), _b(def_b) 
00004 {
00005 }
00006 
00007 SharpIR::SharpIR(PinName apin, int a, float b) : _ain(apin), _a(a), _b(b)
00008 {
00009 }
00010 
00011 float SharpIR::read()
00012 {
00013     float meas = _ain.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
00014     meas = meas * 3300; // Change the value to be in the 0 to 3300 range
00015     float dist = _a * pow(meas , _b);
00016     return dist;   
00017 }