This is some awesome robot code
Dependencies: mbed-rtos mbed QEI
Fork of ICRSEurobot13 by
Diff: Sensors/AvoidDstSensor/AvoidDstSensor.h
- Revision:
- 66:f1d75e51398d
diff -r c979fb1cd3b5 -r f1d75e51398d Sensors/AvoidDstSensor/AvoidDstSensor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sensors/AvoidDstSensor/AvoidDstSensor.h Sun Apr 14 17:22:20 2013 +0000 @@ -0,0 +1,17 @@ +#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; + } +}; \ No newline at end of file