ICRS Eurobot 2013
Dependencies: mbed mbed-rtos Servo QEI
Revision 8:69bdf20cb525, committed 2013-04-04
- Comitter:
- twighk
- Date:
- Thu Apr 04 19:37:05 2013 +0000
- Parent:
- 5:56a5fdd373c9
- Child:
- 9:960410a01e6b
- Commit message:
- CakeSensor, may need recalibration for cake;
Changed in this revision
Sensors/CakeSensor/CakeSensor.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sensors/CakeSensor/CakeSensor.h Thu Apr 04 19:37:05 2013 +0000 @@ -0,0 +1,20 @@ + +// 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); + d = (d < 6 || d > 30)? -1:d; + return d; + } +};
--- a/main.cpp Thu Apr 04 14:44:14 2013 +0000 +++ b/main.cpp Thu Apr 04 19:37:05 2013 +0000 @@ -1,4 +1,4 @@ -#pragma Otime // Compiler Optimisations +//#pragma Otime // Compiler Optimisations // Eurobot13 main.cpp @@ -11,6 +11,7 @@ #include "Sensors/Colour/Colour.h" #include "Sensors/Colour/Led.h" #include "Sensors/Colour/Phototransistor.h" +#include "Sensors/CakeSensor/CakeSensor.h" @@ -25,6 +26,7 @@ void phototransistortest(); void ledphototransistortest(); void colourtest(); +void cakesensortest(); int main() { @@ -33,7 +35,7 @@ *****************/ //motortest(); //encodertest(); - motorencodetest(); + //motorencodetest(); //motorencodetestline(); //motorsandservostest(); //armtest(); @@ -42,6 +44,18 @@ //phototransistortest(); //ledphototransistortest(); //colourtest(); // Red SnR too low + cakesensortest(); +} + +void cakesensortest(){ + wait(1); + pc.printf("cakesensortest"); + + CakeSensor cs(p20); + while(true){ + wait(0.1); + pc.printf("distance: %f\t %f\r\n", cs.Distance(),cs.Distanceincm()); + } } void colourtest(){