Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Serial_To_Bluetooth_Helloworld_WIZwiki-W7500 by
main.cpp
00001 #include "mbed.h" 00002 00003 /* Digital Out Pin Configuration */ 00004 DigitalOut RED(p21); 00005 DigitalOut GREEN(p22); 00006 DigitalOut BLUE(p23); 00007 00008 /* UART Pin Configuration */ 00009 00010 RawSerial pc(USBTX, USBRX);//Serial LOG 00011 Serial bt(p9, p10); // tx, rx to Bluetooth 00012 00013 00014 int main(void) 00015 { 00016 /* baudrate configuration */ 00017 pc.baud(9600); 00018 bt.baud(9600); 00019 00020 pc.printf("Bluetooth RGB LED terminal\n\r"); //pc.printf("WIZwiki-W7500 BT\n\r"); 00021 bt.printf("Bluetooth RGB LED terminal\n\r"); //pc.printf("WIZwiki-W7500 BT\n\r"); 00022 00023 char ch; 00024 char msg[256]; 00025 00026 while(1) 00027 { 00028 /* WIZwiki-W7500 to Bluetooth */ 00029 if(pc.readable()) 00030 { 00031 pc.printf("%s",&msg); 00032 bt.printf("%s",msg); 00033 } 00034 00035 /* Bluetooth to WIZwiki-W7500 */ 00036 if(bt.readable()) 00037 { 00038 ch = bt.getc(); 00039 pc.putc(ch); 00040 00041 /* Control 3 colors LED */ 00042 if(ch == 'r'){ 00043 RED = !RED; 00044 /* Notice RED LED condition to Bluethooth */ 00045 if(RED == 0) bt.printf("RED OFF\n\r"); 00046 else bt.printf("RED ON\n\r"); 00047 }else if(ch == 'g'){ 00048 GREEN = !GREEN; 00049 /* Notice GREEN LED condition to Bluethooth */ 00050 if(GREEN == 0) bt.printf("GREEN OFF\n\r"); 00051 else bt.printf("GREEN ON\n\r"); 00052 }else if(ch == 'b'){ 00053 BLUE = !BLUE; 00054 /* Notice BLUE LED condition to Bluethooth */ 00055 if(BLUE == 0) bt.printf("BLUE OFF\n\r"); 00056 else bt.printf("BLUE ON\n\r"); 00057 } 00058 } 00059 00060 } 00061 }
Generated on Sun Jul 17 2022 10:43:42 by
1.7.2
