Colour sensors calibrated

Dependencies:   mbed-rtos mbed Servo QEI

Fork of ICRSEurobot13 by Thomas Branch

Committer:
twighk
Date:
Fri Apr 05 16:36:27 2013 +0000
Revision:
9:960410a01e6b
Parent:
8:69bdf20cb525
Child:
21:c592bf6a6a2d
update to formula in cake sensor, as the 6cm point is not precice

Who changed what in which revision?

UserRevisionLine numberNew contents of line
twighk 8:69bdf20cb525 1
twighk 8:69bdf20cb525 2 // Eurobot13 CakeSensor.h
twighk 8:69bdf20cb525 3
twighk 8:69bdf20cb525 4 #include "mbed.h"
twighk 8:69bdf20cb525 5
twighk 8:69bdf20cb525 6 class CakeSensor{
twighk 8:69bdf20cb525 7 private:
twighk 8:69bdf20cb525 8 AnalogIn ain;
twighk 8:69bdf20cb525 9
twighk 8:69bdf20cb525 10 public:
twighk 8:69bdf20cb525 11 CakeSensor(PinName analoginpin) : ain(analoginpin){}
twighk 8:69bdf20cb525 12
twighk 8:69bdf20cb525 13 float Distance(){return ain;}
twighk 8:69bdf20cb525 14
twighk 8:69bdf20cb525 15 float Distanceincm(){
twighk 9:960410a01e6b 16 //float d = 5.5/(Distance()-0.13);
twighk 9:960410a01e6b 17 float d = 7.53/(Distance()-0.022);
twighk 8:69bdf20cb525 18 d = (d < 6 || d > 30)? -1:d;
twighk 8:69bdf20cb525 19 return d;
twighk 8:69bdf20cb525 20 }
twighk 8:69bdf20cb525 21 };
twighk 9:960410a01e6b 22 /*
twighk 9:960410a01e6b 23 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}}
twighk 9:960410a01e6b 24 Regress[data, {1, x}, x]
twighk 9:960410a01e6b 25 float d = 5.5/(Distance()-0.13);
twighk 9:960410a01e6b 26
twighk 9:960410a01e6b 27
twighk 9:960410a01e6b 28 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}}
twighk 9:960410a01e6b 29 Regress[data2, {1, x}, x]
twighk 9:960410a01e6b 30 float d = 7.53/(Distance()-0.022);
twighk 9:960410a01e6b 31
twighk 9:960410a01e6b 32 */