GP20A41SK IR sensor
Diff: IR_Dist.h
- Revision:
- 0:a17fcd8e5d32
diff -r 000000000000 -r a17fcd8e5d32 IR_Dist.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IR_Dist.h Mon Jul 03 23:07:51 2017 +0000 @@ -0,0 +1,46 @@ +/* File: IR_Dist.h + * Author: Geert Huisman + * Board: STM NUCLEO F401RE, + * Hardware: IR Range GP20A41SK, + * + * Desc: driver for GP20A41SK IR Distance sensor. The returned range + * is in units of cm meters. + * + * + * +*/ + +/* EXAMPLE +#include "mbed.h" +#include "IR_Dist.h" + +//A0 Analoogin + IR_Dist IRSense(A0); +int main() { + while(1) { + + float distance = IRSense.distance(); + printf("distance %2.0f \n",distance); + wait(1.0); + + } +} +*/ + +#ifndef IR_Dist_H +#define IR_Dist_H +#include "mbed.h" + +class IR_Dist { + public: + IR_Dist(PinName a); + float Equation(); + float distance(); + + private: + AnalogIn IRSens; + int16_t volts; + float som, correction, distance_cm; +}; + +#endif \ No newline at end of file