RN-42XVPでRFCOMMを行うサンプルプログラム。LPC1768のオンボードLEDを受信電文によって点灯・消灯させる。
Fork of RN-42XVPsample by
main.cpp
- Committer:
- nobukuma
- Date:
- 2014-10-29
- Revision:
- 1:ae76705848b6
- Parent:
- 0:66a02c06ec33
- Child:
- 2:f50bbef12435
File content as of revision 1:ae76705848b6:
/** Transistor Gijutsu 2014nen 3gatugo page.64 3syo Buletooth ban LPC810 wo LPC1768 ni henko sita sample program RN-42XVP LPC1768 ------------------- Pin1 VOUT Pin2 p14(rx) or p10 Pin3 p13(tx) or p9 Pin10 GND */ #include "mbed.h" BusOut myleds(LED1, LED2, LED3, LED4); Serial pc(USBTX, USBRX); // (tx, rx) Serial xbee(p9, p10); // (tx,rx) RN-42XVP tuusinyo serial int main() { uint8_t rawData; uint8_t newData; xbee.baud(115200); while(1) { if(1 == xbee.readable()) { rawData = xbee.getc(); pc.printf("rawData = %02x\n",rawData); if(rawData != 0x00) { if(rawData == '+') { newData = 0x0f; } else if(rawData == '-') { newData = 0x00; } else if(rawData == '0') { newData = 0x0a; } else { newData = rawData - '0'; } myleds = newData; } } } }