Blue

Dependencies:   Motor mbed

Fork of Motor_HelloWorld by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
bdragon52
Date:
Tue Nov 14 15:48:42 2017 +0000
Parent:
0:7bbc230e00d6
Commit message:
withblue;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 7bbc230e00d6 -r 294379552123 main.cpp
--- a/main.cpp	Tue Nov 23 16:19:19 2010 +0000
+++ b/main.cpp	Tue Nov 14 15:48:42 2017 +0000
@@ -3,11 +3,102 @@
 #include "mbed.h"
 #include "Motor.h"
 
-Motor m(p23, p6, p5); // pwm, fwd, rev
+
+
+//int main() {
+  //  for (float s= -1.0; s < 1.0 ; s += 0.01) {
+   //    RW.speed(s); 
+   //    wait(0.02);
+   // }
+//}
+
 
-int main() {
-    for (float s= -1.0; s < 1.0 ; s += 0.01) {
-       m.speed(s); 
-       wait(0.02);
+BusOut myled(LED1,LED2,LED3,LED4);
+Serial blue(p28,p27);
+Motor RW(p24, p12, p13); // pwm, fwd, rev
+int main()
+{
+    char bnum=0;
+    char bhit=0;
+    while(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?
+                    myled = bnum - '0'; //current button number will appear on LEDs
+                    switch (bnum) {
+                        case '1': //number button 1
+                            if (bhit=='1') {
+                                RW.speed(1);
+                                //add hit code here
+                            } else {
+                                //add release code here
+                            }
+                            break;
+                        case '2': //number button 2
+                            if (bhit=='1') {
+                                RW.speed(0);
+                                //add hit code here
+                            } else {
+                                //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') {
+                                //add hit code here
+                            } else {
+                                //add release code here
+                            }
+                            break;
+                        case '5': //button 5 up arrow
+                            if (bhit=='1') {
+                                //add hit code here
+                                
+                                 RW.speed(1); 
+                                
+                            } else {
+                                
+                                  RW.speed(0); 
+                                //add release code here
+                            }
+                            break;
+                        case '6': //button 6 down arrow
+                            if (bhit=='1') {
+                                 RW.speed(-1); 
+                                //add hit code here
+                            } else {
+                                RW.speed(0);
+                                //add release code here
+                            }
+                            break;
+                        case '7': //button 7 left arrow
+                            if (bhit=='1') {
+                                //add hit code here
+                            } else {
+                                //add release code here
+                            }
+                            break;
+                        case '8': //button 8 right arrow
+                            if (bhit=='1') {
+                                //add hit code here
+                            } else {
+                                //add release code here
+                            }
+                            break;
+                        default:
+                            break;
+                    }
+                }
+            }
+        }
     }
-}
+}
\ No newline at end of file