logic control

Dependencies:   Motor mbed

Files at this revision

API Documentation at this revision

Comitter:
Ty
Date:
Thu Feb 19 14:30:31 2015 +0000
Commit message:
logic

Changed in this revision

Motor.lib 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r c89dab5f3e1c Motor.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Thu Feb 19 14:30:31 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Motor/#f265e441bcd9
diff -r 000000000000 -r c89dab5f3e1c main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Feb 19 14:30:31 2015 +0000
@@ -0,0 +1,39 @@
+#include "mbed.h"
+#include "Motor.h"
+Serial pc(USBTX,USBRX);//allows communication through the USB
+AnalogIn range(p19);
+float height;
+float rv;
+float dh;
+float er;
+Motor m(p26, p29, p30);
+int counter;
+int main()
+{
+
+    m.speed(0);
+    while(1) {
+        counter=0;
+        m.speed(0);
+        rv=range;
+        height=(-75.7457492123552*pow(rv,2))+(90.6774745565381*rv)+(-4.00358328437282);
+        pc.printf("%f,%f\n",rv,height);
+        pc.printf("Enter desired height\n");
+        pc.scanf("%f",&dh);
+        while(counter<800){
+                       rv=range;
+            height=(-75.7457492123552*pow(rv,2))+(90.6774745565381*rv)+(-4.00358328437282);
+            er=dh-height;
+            pc.printf("%f\n",er);
+            if(er>0) {
+                m.speed(-.5);
+            } 
+            if(er<0) {
+                m.speed(.8);
+            }
+
+        counter = counter+1;
+
+        }//end while
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r c89dab5f3e1c mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Feb 19 14:30:31 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e188a91d3eaa
\ No newline at end of file