Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed ADS1115 StepperMotor SRF05 TPA81new
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 }
Generated on Wed Jul 13 2022 00:38:51 by
1.7.2