Patrick Ruesi / Mbed 2 deprecated Micromouse_alpha_copy_copy

Dependencies:   mbed

Fork of Micromouse_beta by PES2_R2D2.0

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers IRSensor.cpp Source File

IRSensor.cpp

00001 #include <cmath>
00002 #include "IRSensor.h"
00003 
00004 using namespace std;
00005 
00006 
00007 IRSensor::IRSensor(AnalogIn& distance) :
00008     distance(distance)
00009 {}
00010 
00011 IRSensor::~IRSensor() {}
00012 
00013 float IRSensor::read()
00014 {
00015     double d = distance * 3.3f; // Change the value to be in the 0 to 3300 range
00016     
00017     //DONT TOUCH
00018     //y = 14.098x6 - 147.35x5 + 627.68x4 - 1403.5x3 + 1765.1x2 - 1236.9x + 430.44 POLYNOMFUNKTION AUS EXCEL
00019     float f = 14.098f*((d)*(d)*(d)*(d)*(d)*(d)) - 147.35f*((d)*(d)*(d)*(d)*(d)) + 627.68*((d)*(d)*(d)*(d)) - 1403.5f*((d)*(d)*(d)) + 1765.1f*((d)*(d)) - 1236.9f*(d) + 430.44f; // Lesen der Distanz in [mm]  
00020     
00021     return f;
00022 }