ICRS Eurobot 2013

Dependencies:   mbed mbed-rtos Servo QEI

Sensors/CakeSensor/CakeSensor.h

Committer:
twighk
Date:
2013-04-05
Revision:
9:960410a01e6b
Parent:
8:69bdf20cb525

File content as of revision 9:960410a01e6b:


// Eurobot13 CakeSensor.h

#include "mbed.h"

class CakeSensor{
    private:
    AnalogIn ain;
    
    public:
    CakeSensor(PinName analoginpin) : ain(analoginpin){}
    
    float Distance(){return ain;}
    
    float Distanceincm(){
        //float d = 5.5/(Distance()-0.13);
        float d = 7.53/(Distance()-0.022);
        d = (d < 6 || d > 30)? -1:d;
        return d;
    }
};
 /*
 data = {{1/6,0.95},{1/9, 0.86}, {1/12, 0.65}, {1/15, 0.52}, {1/18, 0.44}, {1/21, 0.38}, {1/24, 0.33}, {1/27, 0.30}, {1/30, 0.28}}
 Regress[data, {1, x}, x]
 float d = 5.5/(Distance()-0.13);
 
 
 data2 = {{1/9, 0.86}, {1/12, 0.65}, {1/15, 0.52}, {1/18, 0.44}, {1/21, 0.38}, {1/24, 0.33}, {1/27, 0.30}, {1/30, 0.28}}
 Regress[data2, {1, x}, x]
 float d = 7.53/(Distance()-0.022);
 
 */