remoteContolledRobot via Bluetooth HC06

Dependencies:   PWMOut Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
9acem
Date:
Wed Apr 12 17:01:17 2017 +0000
Commit message:
remote controlled robot bluetooth

Changed in this revision

PWMOut.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 216ced19d510 PWMOut.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PWMOut.lib	Wed Apr 12 17:01:17 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/inst/code/PWMOut/#f1e5739acc27
diff -r 000000000000 -r 216ced19d510 Servo.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Wed Apr 12 17:01:17 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 216ced19d510 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Apr 12 17:01:17 2017 +0000
@@ -0,0 +1,127 @@
+#include "mbed.h"
+#include "Servo.h"
+Serial bt(D10,D2); // rx BT,tx BT
+
+Servo outil(D3);
+Servo porte(D13); //D4 twali D13
+Servo pivot(D5);
+PwmOut avd(D7); //in 1
+PwmOut ard(D6); //in 2
+PwmOut avg(D8); //in 3
+PwmOut arg(D9); //in 4
+
+
+
+
+void avancer() 
+{
+    avd=1.0;
+    ard=0;
+    avg=1.0;
+    arg=0;
+}
+void avancerL()
+{
+    avd=0.5;
+    ard=0;
+    avg=0.5;
+    arg=0;
+}    
+void reculer() 
+{
+    avd=0;
+    ard=1.0;
+    avg=0;
+    arg=1.0;
+}   
+void reculerL() 
+{
+    avd=0;
+    ard=0.5;
+    avg=0;
+    arg=0.5;
+} 
+void droite() 
+{
+    avd=0;
+    ard=0;
+    avg=1.0;
+    arg=0;
+} 
+void droitesp() 
+{
+    avd=0;
+    ard=1.0;
+    avg=1.0;
+    arg=0;
+} 
+void gauche() 
+{
+    avd=1.0;
+    ard=0;
+    avg=0;
+    arg=0;
+} 
+void gauchesp() 
+{
+    avd=1.0;
+    ard=0;
+    avg=0;
+    arg=1.0;
+} 
+void stoop() 
+{
+    avd=0;
+    ard=0;
+    avg=0;
+    arg=0;
+    
+} 
+
+int main() {
+    bt.baud(9600);
+    porte.calibrate(0.00095, 90.0); // Calibrate the servo
+    outil.calibrate(0.00095, 90.0); // Calibrate the servo
+    pivot.calibrate(0.00095, 90.0); // Calibrate the servo
+    /*initialisation des servos*/
+    porte.write(0.15);//porte en haut
+    pivot.write(0.8); //outil avant rotation position initial         
+    wait(1); outil.write(0.92); //outil en bas D11   
+                            
+    while(1) 
+    {
+        //For reading and writing data from/to bluetooth HC-06
+        //check if bluetooth is readable and execute commands to toggle LED
+        if (bt.readable()) 
+            {
+            char input_key=  bt.putc(bt.getc());
+            
+            switch (input_key) 
+                {
+                    
+                  
+                case 'A' :  pivot.write(0.8); //outil avant rotation position initial   pivot.write(0.8)      
+                            wait(1); outil.write(0.92); //outil en bas D11   
+                             break; 
+                case 'B' :  outil.write(0.35);// outil en:  haut outil.write(0.54);
+                            wait(1);  pivot.write(0.38);// outil pivoté 90°:  pivot.write(0.38)
+                             break;
+             case '6' :  porte.write(0.15); //porte en haut 
+                                           break;
+                case '5' :  porte.write(0.83);// porte en bas
+                             break;
+                case 'U': avancer();break;
+                case '1': avancerL ();  break;
+                case 'D': reculer ();break;
+                case '3': reculerL(); break;
+                case '8':  droitesp ();break;
+                case '7': gauchesp ();break;
+                case 'R': droite();break;
+                case 'L': gauche() ;break;
+                case 'S': stoop(); break; 
+                default : stoop();break;
+                }
+            }   
+        
+    }
+}
diff -r 000000000000 -r 216ced19d510 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Apr 12 17:01:17 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/87f2f5183dfb
\ No newline at end of file