Dependencies:   Motor Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
hankpkai
Date:
Mon Apr 24 03:50:45 2017 +0000
Commit message:
MBED_HOVER;

Changed in this revision

Motor.lib Show annotated file Show diff for this revision Revisions of this file
Servo.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 146e770d8ab8 Motor.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Mon Apr 24 03:50:45 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/simon/code/Motor/#f265e441bcd9
diff -r 000000000000 -r 146e770d8ab8 Servo.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Mon Apr 24 03:50:45 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 146e770d8ab8 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Apr 24 03:50:45 2017 +0000
@@ -0,0 +1,132 @@
+#include "mbed.h"
+#include "Servo.h"
+#include "Motor.h"
+
+
+Serial blue(p28,p27);
+
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
+Motor propel(p22, p13, p14);
+
+Servo turn(p23);
+Servo lift(p25);
+
+int main()
+{
+    char bnum=0;
+    char bhit=0;
+    
+        //calibrating
+        lift = 0;
+        wait(0.5);        
+        lift = 1;
+        wait(10);
+        lift = 0;
+        wait(10);
+        
+        
+        turn =0.5;
+        lift = 0;
+        
+    
+    
+    
+    while(1) {
+        led1 = 1;
+        if (blue.getc()=='!') {
+            if (blue.getc()=='B') { //button data packet
+                bnum = blue.getc(); //button number
+                bhit = blue.getc(); //1=hit, 0=release
+                if (blue.getc()==char(~('!' + 'B' + bnum + bhit))) { //checksum OK?
+                    
+                    switch (bnum) {
+                        case '1': //number button 1
+                            if (bhit=='1') {
+                                //add hit code here
+                            } else {
+                                //add release code here
+                            }
+                            break;
+                        case '2': //number button 2
+                            if (bhit=='1') {
+                                propel.speed(1);//add hit code here
+                            } else {
+                                propel.speed(0);//add release code here
+                            }
+                            break;
+                        case '3': //number button 3
+                            if (bhit=='1') {
+                                //add hit code here
+                            } else {
+                                //add release code here
+                            }
+                            break;
+                        case '4': //number button 4
+                            if (bhit=='1') {
+                                propel.speed(-1);//add hit code here
+                            } else {
+                                propel.speed(0);//add release code here
+                            }
+                            break;
+                        case '5': //button 5 up arrow
+                            if (bhit=='1') {
+                                lift = 0.2;
+                                wait(2);
+                                lift = 0.4;
+                                wait(2);
+                                lift = 0.45;
+                                wait(2);
+                                lift = 0.6;
+                                wait(2);
+                                lift = 0.7;
+                                wait(2);
+                                lift = 0.8;
+                                wait(2);
+                                lift = 0.9;
+                                wait(2);
+                                lift= 1;
+                                
+                                
+                                
+                                
+                                
+                            } else {
+                               //lift = 0.5;//add release code here
+                            }
+                            break;
+                        case '6': //button 6 down arrow
+                            if (bhit=='1') {
+                                lift = 0;//add hit code here
+                            } else {
+                                lift = 0;//add release code here
+                            }
+                            break;
+                        case '7': //button 7 left arrow
+                            if (bhit=='1') {
+                                
+                                turn = 1;//add hit code here
+                            } else {
+                                turn = 0.5;//add release code here
+                            }
+                            break;
+                        case '8': //button 8 right arrow
+                            if (bhit=='1') {
+                                
+                                turn = 0;//add hit code here
+                            } else {
+                                turn = 0.5;//add release code here
+                            }
+                            break;
+                        default:
+                            break;
+                    }
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 146e770d8ab8 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Apr 24 03:50:45 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/97feb9bacc10
\ No newline at end of file