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.
Dependencies: mbed
Fork of mbed_bluetooth_HC-06_communication by
main.cpp
00001 #include "mbed.h" 00002 00003 Serial bt(PA_11, PA_12); 00004 Serial pc(USBTX,USBRX); 00005 DigitalOut myled(LED2); 00006 00007 int main() 00008 { 00009 bt.baud(9600); 00010 //prints data on mobile 00011 bt.printf("Connection Established"); 00012 //print data on pc terminal 00013 pc.printf("Connection Established"); 00014 while(1) { 00015 //For reading and writing data from/to bluetooth HC-06 00016 //check if bluetooth is readable and execute commands to toggle LED 00017 if (bt.readable()) { 00018 char input_key= bt.putc(bt.getc()); 00019 //tutn on LED if "y" is entered 00020 if(input_key == 'y') { 00021 myled = 1; 00022 bt.printf("LED is ON"); 00023 } 00024 //turn on LED if "n" is entered 00025 if(input_key == 'n') { 00026 myled = 0; 00027 bt.printf("LED is OFF"); 00028 } 00029 } 00030 00031 //For reading and writing data from/to pc terminal 00032 //check if pc is readable and execute commands to toggle LED 00033 if (pc.readable()) { 00034 char input_key= pc.putc(pc.getc()); 00035 00036 if(input_key == 'y') { 00037 myled = 1; 00038 pc.printf("LED is ON"); 00039 } 00040 if(input_key == 'n') { 00041 myled = 0; 00042 pc.printf("LED is OFF"); 00043 } 00044 } 00045 } 00046 }
Generated on Wed Jul 13 2022 23:18:07 by
1.7.2
