Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed XBee mbed-rtos
xbeeio5.cpp@5:d01cf03058f6, 2012-04-12 (annotated)
- Committer:
- yamaguch
- Date:
- Thu Apr 12 10:21:11 2012 +0000
- Revision:
- 5:d01cf03058f6
- Parent:
- 0:34e0352d7396
- Child:
- 6:d456c203adb6
1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yamaguch | 0:34e0352d7396 | 1 | #include "XBee.h" |
yamaguch | 0:34e0352d7396 | 2 | |
yamaguch | 0:34e0352d7396 | 3 | void xbeeio5() { |
yamaguch | 5:d01cf03058f6 | 4 | XBee xbee(p9, p10); |
yamaguch | 5:d01cf03058f6 | 5 | xbee.baud(115200); |
yamaguch | 0:34e0352d7396 | 6 | xbee.init(); |
yamaguch | 0:34e0352d7396 | 7 | |
yamaguch | 5:d01cf03058f6 | 8 | xbee.setDestination(XBeeAddress64(0x0013A200, 0x40666193)); |
yamaguch | 5:d01cf03058f6 | 9 | |
yamaguch | 5:d01cf03058f6 | 10 | xbee.sendRemoteCommand("D1", 2); |
yamaguch | 0:34e0352d7396 | 11 | |
yamaguch | 5:d01cf03058f6 | 12 | // clear receive buffer |
yamaguch | 5:d01cf03058f6 | 13 | while (xbee.receive()) |
yamaguch | 5:d01cf03058f6 | 14 | ; |
yamaguch | 0:34e0352d7396 | 15 | |
yamaguch | 0:34e0352d7396 | 16 | for (int i = 0; i < 60; i++) { |
yamaguch | 0:34e0352d7396 | 17 | xbee.sendRemoteCommand("IS"); |
yamaguch | 0:34e0352d7396 | 18 | if (xbee.receive() == XBee::RemoteCommandResponse) { |
yamaguch | 5:d01cf03058f6 | 19 | XBeeCommandData data(16); |
yamaguch | 5:d01cf03058f6 | 20 | xbee.scan(data); |
yamaguch | 5:d01cf03058f6 | 21 | |
yamaguch | 0:34e0352d7396 | 22 | IOSample sample(data); |
yamaguch | 0:34e0352d7396 | 23 | printf("AD1 = %3.2fV\n", 3.3 * sample.ad[1] / 1023); |
yamaguch | 0:34e0352d7396 | 24 | } |
yamaguch | 0:34e0352d7396 | 25 | wait(1); |
yamaguch | 0:34e0352d7396 | 26 | } |
yamaguch | 0:34e0352d7396 | 27 | |
yamaguch | 0:34e0352d7396 | 28 | printf("done.\n"); |
yamaguch | 0:34e0352d7396 | 29 | } |