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-rtos mbed QEI
Sensors/AvoidDstSensor/AvoidDstSensor.h
- Committer:
- madcowswe
- Date:
- 2013-04-14
- Revision:
- 66:f1d75e51398d
File content as of revision 66:f1d75e51398d:
#include "mbed.h"
class AvoidDstSensor{
private:
AnalogIn ain;
public:
AvoidDstSensor(PinName analoginpin) : ain(analoginpin){}
float Raw(){return ain;}
float Distanceincm(){
float d = ((1.0f/ain)-0.5f)*(1.0f/0.11f);
d = (d < 10 || d > 50)? -1:d;
return d;
}
};