情報物理III / Mbed 2 deprecated XBeeTest-sprintf

Dependencies:   SoftwareSerial mbed

Fork of XBeeTest by Vlad Cazan

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "SoftwareSerial.h"
00003 
00004 SoftwareSerial xbee1(D3, D2);
00005 DigitalOut myled(LED1);
00006 Serial pc(USBTX, USBRX);
00007 
00008 int main() {
00009     char buffer[256];
00010     char *p;
00011     
00012     xbee1.baud(9600);
00013     int count = 1;
00014     myled = 0;
00015 
00016     while (1) {
00017             sprintf(buffer, "%d: (yokota) hello.\r\n", count++);
00018             pc.puts(buffer); //for debugging: print to pc
00019             p = buffer;
00020             while (*p) {
00021                 xbee1.putc(*p++);
00022                 wait_ms(2); //required for stable communication
00023             }   
00024             wait_ms(1000);
00025             myled = 1 - myled;
00026     }
00027 }