Roboshark / Mbed 2 deprecated IrSensorDistanceMessureFornt

Dependencies:   mbed

Fork of IrSensorDistanceMessure by Roboshark

main.cpp

Committer:
ahlervin
Date:
2018-05-06
Revision:
1:8184ab7e4395
Parent:
0:a49ea5211c34

File content as of revision 1:8184ab7e4395:

#include "mbed.h"
 
 //Distandce Messure IR Sensor
 //Meas = f(s)
 
AnalogIn analog_value(PC_2);

    const float PF1 = 6.1767f*pow(10.0f,-10);
    const float PF2 = -1.9975f*pow(10.0f,-6);
    const float PF3 = 0.0024f;
    const float PF4 = -1.3299f;
    const float PF5 = 351.1557f;
    float disF;
    int roundF;
    
int main() {
    
    float measF;
    printf("\nDistance Test Sensoren Front\n");
    printf("misst die Distanz vom Wagenrad bis Objekt\n");
    wait(1.5);
    
    while(1) {

        
        measF = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
        measF = measF * 1000; // Change the value to be in the 0 to 1000 range
        disF = PF1*pow(measF,4)+PF2*pow(measF,3)+PF3*pow(measF,2)+PF4*measF+PF5; //disF = f(measF)
        roundF = disF*100;
        disF = roundF/100.0-20.0;
        
        printf("Distanz Front = %f\n", disF);
        
        wait(0.7); // 1 s
    }
}