Buletooth module(RX-42XVP) sample program
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 /** 00002 Transistor Gijutsu 2014nen 3gatugo page.64 3syo 00003 Buletooth ban 00004 LPC810 wo LPC1768 ni henko sita sample program 00005 00006 00007 RN-42XVP LPC1768 00008 ------------------- 00009 Pin1 VOUT 00010 Pin2 p14(rx) 00011 Pin3 p13(tx) 00012 Pin10 GND 00013 00014 */ 00015 #include "mbed.h" 00016 00017 BusOut myleds(LED1, LED2, LED3, LED4); 00018 00019 Serial pc(USBTX, USBRX); // (tx, rx) 00020 Serial xbee(p13, p14); // (tx,rx) RN-42XVP tuusinyo serial 00021 00022 int main() 00023 { 00024 uint8_t rawData; 00025 uint8_t newData; 00026 00027 xbee.baud(115200); 00028 00029 while(1) { 00030 00031 if(1 == xbee.readable()) { 00032 rawData = xbee.getc(); 00033 00034 pc.printf("rawData = %02x\n",rawData); 00035 00036 if(rawData != 0x00) { 00037 if(rawData == '+') { 00038 newData = 0x0f; 00039 } else if(rawData == '-') { 00040 newData = 0x00; 00041 } else if(rawData == '0') { 00042 newData = 0x0a; 00043 } else { 00044 newData = rawData - '0'; 00045 } 00046 00047 myleds = newData; 00048 00049 00050 } 00051 00052 } 00053 } 00054 }
Generated on Mon Jul 18 2022 04:45:00 by
1.7.2