Control car by bluetooth.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Pairam
Date:
Sat Oct 28 09:42:08 2017 +0000
Commit message:
Control car by Bluetooth.

Changed in this revision

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 e35b1281c62b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Oct 28 09:42:08 2017 +0000
@@ -0,0 +1,52 @@
+#include "mbed.h" 
+
+Serial blue (PA_9, PA_10 );
+PwmOut PwmA(D3);
+PwmOut PwmB(D6);
+PwmOut PwmA1(D5);
+PwmOut PwmB1(D9);
+ 
+ int main(){
+    blue.baud(9600);
+    while(1){
+    if(blue.readable()){
+    char key = blue.putc(blue.getc());
+    PwmA.period_ms(5);
+    PwmB.period_ms(5);
+    PwmA1.period_ms(5);
+    PwmB1.period_ms(5);
+        if(key == 'f'){
+        PwmA.pulsewidth_ms(3);
+        PwmB.pulsewidth_ms(3);
+        PwmA1.pulsewidth_ms(0);
+        PwmB1.pulsewidth_ms(0);
+        
+        }  
+        else if(key =='b'){
+        PwmA.pulsewidth_ms(0);
+        PwmB.pulsewidth_ms(0);
+        PwmA1.pulsewidth_ms(3);
+        PwmB1.pulsewidth_ms(3);
+        }
+        else if(key =='l'){
+        PwmA.pulsewidth_ms(3);
+        PwmB.pulsewidth_ms(0);
+        PwmA1.pulsewidth_ms(0);
+        PwmB1.pulsewidth_ms(3);
+            }
+        else if(key =='r'){
+        PwmA.pulsewidth_ms(0);
+        PwmB.pulsewidth_ms(3);
+        PwmA1.pulsewidth_ms(3);
+        PwmB1.pulsewidth_ms(0);
+            }
+        else{
+        PwmA.pulsewidth_ms(0);
+        PwmB.pulsewidth_ms(0);
+        PwmA1.pulsewidth_ms(0);
+        PwmB1.pulsewidth_ms(0);
+          
+            }
+        }         
+    }
+}
diff -r 000000000000 -r e35b1281c62b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Oct 28 09:42:08 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/a97add6d7e64
\ No newline at end of file