ICRS Eurobot 2013
Dependencies: mbed mbed-rtos Servo QEI
Sensors/CakeSensor/CakeSensor.h@8:69bdf20cb525, 2013-04-04 (annotated)
- Committer:
- twighk
- Date:
- Thu Apr 04 19:37:05 2013 +0000
- Revision:
- 8:69bdf20cb525
- Child:
- 9:960410a01e6b
CakeSensor, may need recalibration for cake;
Who changed what in which revision?
User | Revision | Line number | New 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 | 8:69bdf20cb525 | 16 | float d = 5.5/(Distance()-0.13); |
twighk | 8:69bdf20cb525 | 17 | d = (d < 6 || d > 30)? -1:d; |
twighk | 8:69bdf20cb525 | 18 | return d; |
twighk | 8:69bdf20cb525 | 19 | } |
twighk | 8:69bdf20cb525 | 20 | }; |