blue
Dependencies: mbed
main.cpp
00001 #include "mbed.h" 00002 00003 Serial bt(D10,D2); // D10 va su RX; D2 va su TX 00004 Serial pc(USBTX,USBRX); 00005 DigitalOut myled(D13); 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 //tutn 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 } 00047
Generated on Mon Jul 18 2022 17:57:37 by 1.7.2