Code

Dependencies:   mbed QEI MPU6050 TextLCD

Files at this revision

API Documentation at this revision

Comitter:
belsarekaiwalya
Date:
Sat Mar 11 09:43:33 2017 +0000
Child:
1:59c416ccba42
Commit message:
Worked perfectly with 16x2 LCD and Bluetooth module.; ;

Changed in this revision

TextLCD.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Sat Mar 11 09:43:33 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Mar 11 09:43:33 2017 +0000
@@ -0,0 +1,150 @@
+/*#include "mbed.h"
+DigitalOut myled(LED1);
+
+int main() {
+    while(1) 
+    {
+        lcd.locate(1,0);
+        lcd.printf("Hello\n");
+        //myled = 1; // LED is ON
+        //wait(0.2); // 200 ms
+        //myled = 0; // LED is OFF
+        //wait(1.0); // 1 sec
+    
+    }
+}
+*/
+#include "mbed.h"
+#include "TextLCD.h"
+TextLCD lcd(PA_0,PA_1,PA_4,PB_0,PC_1,PC_0); // rs, e, d4-d7
+DigitalOut m1dir1(PB_3);
+DigitalOut m1dir2(PB_5);
+DigitalOut m2dir1(PB_4);
+DigitalOut m2dir2(PB_10);
+PwmOut pwm1(PA_8);
+PwmOut pwm2(PA_9); 
+
+Serial bt(PC_6,PC_7);//tx,rx
+PwmOut mypwm(LED1);
+DigitalOut myled(LED1);
+Serial serial(USBTX, USBRX);
+
+int ch ;
+int main()
+{
+    bt.baud(9600);
+    serial.baud(9600);
+    while(1) 
+    {
+        if(bt.readable()) 
+        {
+         ch =  bt.getc();
+         lcd.cls();  
+         switch(ch)
+            {
+              case 'w':
+              lcd.cls();
+              serial.printf("Forward\n");
+              lcd.locate(1,0);
+              lcd.printf("Forward\n");
+              void front();
+              break;
+              
+              case 'a':
+              lcd.cls();
+              serial.printf("Left\n");
+              lcd.locate(1,0);
+              lcd.printf("Left\n");
+              void left();
+              break; 
+              
+              case 's':
+              lcd.cls();
+              serial.printf("Back\n");
+              lcd.locate(1,0);
+              lcd.printf("Back\n");
+              void back();
+              break; 
+              
+              case 'd':
+              lcd.cls();
+              serial.printf("Right\n");
+              lcd.locate(1,0);
+              lcd.printf("Right\n");
+              void right();
+              break;
+              
+              default:
+              serial.printf("Brake");
+              lcd.cls();
+              lcd.locate(1,0);
+              lcd.printf("Brake");
+              void brake();
+                
+                }
+        
+        }
+        
+        //serial.printf("%c\n",ch);
+    }
+}
+void front()
+{
+    m1dir1 = 1;
+    m1dir2 = 0;
+    m2dir1 = 1;
+    m2dir2 = 0;
+    pwm1.period(0.001f); 
+    pwm1=0.5;
+    pwm2.period(0.001f); 
+    pwm2=0.5; 
+    
+}
+void brake()
+{
+    m1dir1 = 1;
+    m1dir2 = 0;
+    m2dir1 = 1;
+    m2dir2 = 0;
+    pwm1.period(0.001f); 
+    pwm1=0.0f;
+    pwm2.period(0.001f); 
+    pwm2=0.0f; 
+    
+}
+void back()
+{
+    m1dir1 = 0;
+    m1dir2 = 1;
+    m2dir1 = 0;
+    m2dir2 = 1;
+    pwm1.period(0.001f); 
+    pwm1=0.5;
+    pwm2.period(0.001f); 
+    pwm2=0.5;
+    
+}
+void left()
+{
+    m1dir1 = 0;
+    m1dir2 = 1;
+    m2dir1 = 0;
+    m2dir2 = 0;
+    pwm1.period(0.001f); 
+    pwm1=0.5f;
+    pwm2.period(0.001f); 
+    pwm2=0.0f; 
+    
+}
+void right()
+{
+    m1dir1 = 0;
+    m1dir2 = 0;
+    m2dir1 = 0;
+    m2dir2 = 1;
+    pwm1.period(0.001f); 
+    pwm1=0.0f;
+    pwm2.period(0.001f); 
+    pwm2=0.5; 
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Mar 11 09:43:33 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e1686b8d5b90
\ No newline at end of file