Nobuaki Aoki / Mbed 2 deprecated RN-42XVPsample

Dependencies:   mbed

Fork of RN-42XVPsample by suu pen

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002   RN-42XVPによるRFCOMM通信のサンプルプログラム(mbed側)
00003     ・受け取った電文の1-4ビット目でLPC1768のLED1-4を点灯・消灯させる
00004 
00005 RN-42XVP   LPC1768
00006 -------------------
00007 Pin1       VOUT
00008 Pin2       p14(rx) or p10
00009 Pin3       p13(tx) or p9
00010 Pin10      GND   
00011 */
00012 #include "mbed.h"
00013 
00014 BusOut leds(LED1, LED2, LED3, LED4);
00015 Serial pc(USBTX, USBRX); // For Debug
00016 Serial xbee(p9, p10);    // RN-42XVP
00017 
00018 int main()
00019 {
00020     uint8_t rawData;
00021  
00022     xbee.baud(115200);
00023 
00024     while(1) {
00025         if (xbee.readable() == 1) {
00026             rawData = xbee.getc();
00027             pc.printf("rawData = %02x\n", rawData);
00028             if (rawData <= 0x0f) {
00029                 leds = rawData;
00030             }
00031         }
00032     }
00033 }