LED Cortrol HC-05 Bluetooth LCP1768. Type R G B in terminal to turn on led R G B

Dependencies:   mbed

Fork of Serial_To_Bluetooth_Helloworld_WIZwiki-W7500 by WIZnet

Files at this revision

API Documentation at this revision

Comitter:
Tuxitheone
Date:
Fri Jul 08 09:36:57 2016 +0000
Parent:
0:22832bff21a1
Commit message:
HC-05 Bluetooth LCP1768

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Feb 02 08:05:34 2016 +0000
+++ b/main.cpp	Fri Jul 08 09:36:57 2016 +0000
@@ -1,22 +1,24 @@
 #include "mbed.h"
 
 /* Digital Out Pin Configuration */
-DigitalOut RED(D8,1);
-DigitalOut GREEN(D9,1);
-DigitalOut BLUE(D10,1);
+DigitalOut RED(p21);
+DigitalOut GREEN(p22);
+DigitalOut BLUE(p23);
 
 /* UART Pin Configuration */
-Serial pc(USBTX, USBRX);    
-Serial bt(D1,D0);           
+
+RawSerial pc(USBTX, USBRX);//Serial LOG
+Serial bt(p9, p10); // tx, rx to Bluetooth         
 
 
 int main(void)
 {   
     /* baudrate configuration */
-    pc.baud(115200);
+    pc.baud(9600);
     bt.baud(9600);
     
-    pc.printf("WIZwiki-W7500 BT\n\r");
+    pc.printf("Bluetooth RGB LED terminal\n\r"); //pc.printf("WIZwiki-W7500 BT\n\r");
+    bt.printf("Bluetooth RGB LED terminal\n\r"); //pc.printf("WIZwiki-W7500 BT\n\r");
     
     char ch;
     char msg[256];
@@ -26,7 +28,7 @@
         /* WIZwiki-W7500 to Bluetooth */
         if(pc.readable())
         {
-            pc.scanf("%s",&msg);
+            pc.printf("%s",&msg);
             bt.printf("%s",msg);
         }
         
@@ -40,18 +42,18 @@
             if(ch == 'r'){
                 RED = !RED;
                 /* Notice RED LED condition to Bluethooth */
-                if(RED == 0)    bt.printf("RED ON");
-                else            bt.printf("RED OFF");
+                if(RED == 0)    bt.printf("RED OFF\n\r");
+                else            bt.printf("RED ON\n\r");
             }else if(ch == 'g'){
                 GREEN = !GREEN;
                 /* Notice GREEN LED condition to Bluethooth */
-                if(GREEN == 0)    bt.printf("GREEN ON");
-                else              bt.printf("GREEN OFF");
+                if(GREEN == 0)    bt.printf("GREEN OFF\n\r");
+                else              bt.printf("GREEN ON\n\r");
             }else if(ch == 'b'){
                 BLUE = !BLUE;
                 /* Notice BLUE LED condition to Bluethooth */
-                if(BLUE == 0)    bt.printf("BLUE ON");
-                else             bt.printf("BLUE OFF");
+                if(BLUE == 0)    bt.printf("BLUE OFF\n\r");
+                else             bt.printf("BLUE ON\n\r");
             }
         }