Geert Huisman / IR_Distance
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers IR_Dist.h Source File

IR_Dist.h

00001 /* File: IR_Dist.h
00002  * Author: Geert Huisman  
00003  * Board: STM NUCLEO F401RE, 
00004  * Hardware: IR Range GP20A41SK,  
00005  *
00006  * Desc: driver for GP20A41SK IR Distance sensor.  The returned range
00007  * is in units of cm meters.
00008  *  
00009  *       
00010  *
00011 */
00012 
00013 /* EXAMPLE
00014 #include "mbed.h"
00015 #include "IR_Dist.h"
00016 
00017 //A0 Analoogin
00018    IR_Dist IRSense(A0); 
00019 int main() {
00020     while(1) {
00021         
00022      float distance = IRSense.distance();   
00023       printf("distance %2.0f   \n",distance);
00024       wait(1.0);  
00025         
00026     }
00027 }
00028 */
00029 
00030 #ifndef IR_Dist_H
00031 #define IR_Dist_H
00032 #include "mbed.h"
00033  
00034 class IR_Dist {
00035   public:
00036     IR_Dist(PinName a);
00037     float Equation();
00038     float distance();
00039      
00040     private:
00041         AnalogIn IRSens;
00042         int16_t volts;
00043         float som, correction, distance_cm;
00044 };
00045  
00046 #endif