final code (doesnt work)
Dependencies: mbed Servo C12832_lcd
IR_Dist.h@1:52cda602892c, 2018-11-23 (annotated)
- Committer:
- mazmonem
- Date:
- Fri Nov 23 16:37:21 2018 +0000
- Revision:
- 1:52cda602892c
- Parent:
- 0:65b5886093c5
final code;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mazmonem | 0:65b5886093c5 | 1 | /* File: IR_Dist.h |
mazmonem | 0:65b5886093c5 | 2 | * Author: Geert Huisman |
mazmonem | 0:65b5886093c5 | 3 | * Board: STM NUCLEO F401RE, |
mazmonem | 0:65b5886093c5 | 4 | * Hardware: IR Range GP20A41SK, |
mazmonem | 0:65b5886093c5 | 5 | * |
mazmonem | 0:65b5886093c5 | 6 | * Desc: driver for GP20A41SK IR Distance sensor. The returned range |
mazmonem | 0:65b5886093c5 | 7 | * is in units of cm meters. |
mazmonem | 0:65b5886093c5 | 8 | * |
mazmonem | 0:65b5886093c5 | 9 | * |
mazmonem | 0:65b5886093c5 | 10 | * |
mazmonem | 0:65b5886093c5 | 11 | */ |
mazmonem | 0:65b5886093c5 | 12 | |
mazmonem | 0:65b5886093c5 | 13 | /* EXAMPLE |
mazmonem | 0:65b5886093c5 | 14 | #include "mbed.h" |
mazmonem | 0:65b5886093c5 | 15 | #include "IR_Dist.h" |
mazmonem | 0:65b5886093c5 | 16 | |
mazmonem | 0:65b5886093c5 | 17 | //A0 Analoogin |
mazmonem | 0:65b5886093c5 | 18 | IR_Dist IRSense(A0); |
mazmonem | 0:65b5886093c5 | 19 | int main() { |
mazmonem | 0:65b5886093c5 | 20 | while(1) { |
mazmonem | 0:65b5886093c5 | 21 | |
mazmonem | 0:65b5886093c5 | 22 | float distance = IRSense.distance(); |
mazmonem | 0:65b5886093c5 | 23 | printf("distance %2.0f \n",distance); |
mazmonem | 0:65b5886093c5 | 24 | wait(1.0); |
mazmonem | 0:65b5886093c5 | 25 | |
mazmonem | 0:65b5886093c5 | 26 | } |
mazmonem | 0:65b5886093c5 | 27 | } |
mazmonem | 0:65b5886093c5 | 28 | */ |
mazmonem | 0:65b5886093c5 | 29 | |
mazmonem | 0:65b5886093c5 | 30 | #ifndef IR_Dist_H |
mazmonem | 0:65b5886093c5 | 31 | #define IR_Dist_H |
mazmonem | 0:65b5886093c5 | 32 | #include "mbed.h" |
mazmonem | 0:65b5886093c5 | 33 | |
mazmonem | 0:65b5886093c5 | 34 | class IR_Dist { |
mazmonem | 0:65b5886093c5 | 35 | public: |
mazmonem | 0:65b5886093c5 | 36 | IR_Dist(PinName a); |
mazmonem | 0:65b5886093c5 | 37 | float Equation(); |
mazmonem | 0:65b5886093c5 | 38 | float distance(); |
mazmonem | 0:65b5886093c5 | 39 | |
mazmonem | 0:65b5886093c5 | 40 | private: |
mazmonem | 0:65b5886093c5 | 41 | AnalogIn IRSens; |
mazmonem | 0:65b5886093c5 | 42 | int16_t volts; |
mazmonem | 0:65b5886093c5 | 43 | float som, correction, distance_cm; |
mazmonem | 0:65b5886093c5 | 44 | }; |
mazmonem | 0:65b5886093c5 | 45 | |
mazmonem | 0:65b5886093c5 | 46 | #endif |