hc05 and ln298

Dependencies:   mbed-src

Files at this revision

API Documentation at this revision

Comitter:
leoferreira
Date:
Wed May 11 00:38:02 2016 +0000
Commit message:
Bluetooth hc05 and driver ln298

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-src.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r e289939710df main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 11 00:38:02 2016 +0000
@@ -0,0 +1,74 @@
+#include "mbed.h"
+ 
+PwmOut ena(D7);
+PwmOut enb(D6);
+DigitalOut in1 (D5);
+DigitalOut in2 (D4);
+DigitalOut in3 (D3);
+DigitalOut in4 (D2);
+ 
+Serial pc(USBTX, USBRX); // liga direto
+
+
+Serial blue(PTC4, PTC3);
+ 
+float vela=1.0f; //ENGINE SPEED
+float velb=0.05935f; //ENGINE SPEED
+ 
+int main()
+{
+    char estado='x';
+    blue.baud(9600);
+ 
+    while(1){
+        if(blue.readable()>0) {
+            estado=blue.getc(); //<- HOW TO READ THE CHARACTER THAT SENT WITH THE APPLICATION 
+ 
+            if(estado=='f') {          // Vai para frente
+                ena.write(vela);
+                in1.write(1);
+                in2.write(0);
+                enb.write(velb);
+                in3.write(0);
+                in4.write(1);
+                
+            }
+            if(estado=='a') {         // Vai para tras
+                ena.write(vela);
+                in1.write(0);
+                in2.write(1);
+                enb.write(velb);
+                in3.write(1);
+                in4.write(0);
+            }
+            if(estado=='d') {        // Vai para direita
+                ena.write(vela);
+                in1.write(0);
+                in2.write(1);
+                enb.write(velb);
+                in3.write(0);
+                in4.write(1);
+            }
+            if(estado=='e') {         // Vai para a esquerda
+                ena.write(vela);
+                in1.write(1);
+                in2.write(0);
+                enb.write(velb);
+                in3.write(1);
+                in4.write(0);
+            }
+ 
+           /* if(estado=='b') {         // BACK
+                motor1a.write(0);
+                motor2a.write(0);
+                motor1b.write(vel);
+                motor2b.write(vel);
+            }*/
+            if (estado =='o') {         // ON REMOTE SENSING
+ 
+            }
+            if  (estado=='x') {         // OFF REMOTE SENSING
+            }
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r e289939710df mbed-src.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-src.lib	Wed May 11 00:38:02 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-src/#a11c0372f0ba