Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-rtos mbed QEI
Revision 10:1f0cf0182067, committed 2013-04-05
- Comitter:
- twighk
- Date:
- Fri Apr 05 16:40:52 2013 +0000
- Parent:
- 7:4340355261f9
- Parent:
- 9:960410a01e6b
- Child:
- 11:bbddc908c78c
- Commit message:
- merge fix;
Changed in this revision
| 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 Fri Apr 05 16:40:52 2013 +0000
@@ -0,0 +1,32 @@
+
+// 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);
+
+ */
\ No newline at end of file
--- a/main.cpp Fri Apr 05 16:37:36 2013 +0000
+++ b/main.cpp Fri Apr 05 16:40:52 2013 +0000
@@ -1,4 +1,4 @@
-#pragma Otime // Compiler Optimisations
+//#pragma Otime // Compiler Optimisations
// Eurobot13 main.cpp
@@ -67,6 +67,7 @@
#include "Actuators/MainMotors/MainMotor.h"
#include "Sensors/Encoders/Encoder.h"
#include "Sensors/Colour/Colour.h"
+#include "Sensors/CakeSensor/CakeSensor.h"
@@ -81,6 +82,7 @@
void phototransistortest();
void ledphototransistortest();
void colourtest();
+void cakesensortest();
int main() {
@@ -98,6 +100,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(){