Macchina con bluetooth

Dependencies:   MotorMR001-004 mbed

Files at this revision

API Documentation at this revision

Comitter:
Mattinico
Date:
Sat Nov 12 18:29:24 2016 +0000
Commit message:
k

Changed in this revision

MotorMR001-004.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 9cefbd1e13a1 MotorMR001-004.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MotorMR001-004.lib	Sat Nov 12 18:29:24 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/MEM/code/MotorMR001-004/#f265e441bcd9
diff -r 000000000000 -r 9cefbd1e13a1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Nov 12 18:29:24 2016 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h" 
+#include "Motor.h" 
+Serial pc (SERIAL_TX, SERIAL_RX);
+Motor m1(D10, D8, D9); //pwm (E1), fwd (1A), rev (1B) 
+Motor m2(D5, D6, D7); //pwm (E2), fwd (2A), rev (2B)  
+RawSerial hc05(D8, D2);
+
+int main() { 
+    char a; 
+    pc.baud(9600); // setto il baud rate della porta seriale pc 
+    hc05.baud(9600); // setto il baud rate della porta rawserial hc05 
+    while(1) { 
+        if(hc05.readable()) { // se e’¨ stato ricevuto un carattere
+            a=hc05.getc(); // assegna il carattere ricevuto alla var a
+            if (a=='v') { 
+                m1.speed(1); 
+                m2.speed(1); 
+                wait(1.5);
+            } 
+            else if(a=='d'){
+                m1.speed(0.6);
+                m2.speed(-0.6);
+                wait(1);
+            }
+            else if(a=='s'){
+                m1.speed(-0.6);
+                m2.speed(0.6);
+                wait(1);
+            } 
+            /*else if(a=='p'{ 
+                m1.speed(0); 
+                m2.speed(0);
+                } */
+        } 
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 9cefbd1e13a1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Nov 12 18:29:24 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0ab6a29f35bf
\ No newline at end of file