![](/media/cache/profiles/2e74f94b232c5a0cc3e75b4eaaf64c90.jpg.50x50_q85.jpg)
Hepta communication
Dependencies: Hepta9axis HeptaBattery HeptaXbee mbed
Fork of Lab7-01_template by
main.cpp@18:113faeac45c2, 2018-08-21 (annotated)
- Committer:
- HEPTA
- Date:
- Tue Aug 21 05:55:36 2018 +0000
- Revision:
- 18:113faeac45c2
- Parent:
- 16:3d2684da4695
protocol
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:bdbd3d6fc5d5 | 1 | #include "mbed.h" |
umeume | 2:1c5cdb2c3e0f | 2 | #include "HeptaXbee.h" |
umeume | 2:1c5cdb2c3e0f | 3 | #include "Hepta9axis.h" |
umeume | 2:1c5cdb2c3e0f | 4 | #include "HeptaBattery.h" |
umeume | 2:1c5cdb2c3e0f | 5 | |
umeume | 2:1c5cdb2c3e0f | 6 | Serial pc(USBTX,USBRX); |
HEPTA | 15:9c52d5529b9d | 7 | |
umeume | 2:1c5cdb2c3e0f | 8 | |
HEPTA | 15:9c52d5529b9d | 9 | |
umeume | 5:c5ccb1b07e8f | 10 | |
umeume | 2:1c5cdb2c3e0f | 11 | int main() |
umeume | 2:1c5cdb2c3e0f | 12 | { |
HEPTA | 15:9c52d5529b9d | 13 | int i = 0,rcmd=0,cmdflag=0; |
HEPTA | 15:9c52d5529b9d | 14 | |
HEPTA | 15:9c52d5529b9d | 15 | xbee.printf("Count Up!\r\n"); |
HEPTA | 15:9c52d5529b9d | 16 | while(1) { |
HEPTA | 15:9c52d5529b9d | 17 | xbee.printf("num = %d\r\n",i); |
HEPTA | 15:9c52d5529b9d | 18 | i++; |
HEPTA | 15:9c52d5529b9d | 19 | wait(1.0); |
HEPTA | 16:3d2684da4695 | 20 | xbee.xbee_receive(&rcmd,&cmdflag); |
HEPTA | 15:9c52d5529b9d | 21 | pc.printf("rcmd=%d, cmdflag=%d\r\n",rcmd, cmdflag); |
HEPTA | 15:9c52d5529b9d | 22 | if (cmdflag == 1) { |
HEPTA | 15:9c52d5529b9d | 23 | if (rcmd == 'a') { |
HEPTA | 15:9c52d5529b9d | 24 | pc.printf("Command Get %d\r\n",rcmd); |
HEPTA | 15:9c52d5529b9d | 25 | xbee.printf("HEPTA Uplink OK\r\n"); |
HEPTA | 15:9c52d5529b9d | 26 | pc.printf("===================\r\n"); |
HEPTA | 15:9c52d5529b9d | 27 | pc.printf("Accel sensing Mode\r\n"); |
HEPTA | 15:9c52d5529b9d | 28 | pc.printf("===================\r\n"); |
HEPTA | 15:9c52d5529b9d | 29 | for(int ii = 0; ii < 10; ii++) { |
HEPTA | 15:9c52d5529b9d | 30 | n_axis.sen_acc(&ax,&ay,&az); |
HEPTA | 15:9c52d5529b9d | 31 | battery.vol(&bt); |
HEPTA | 15:9c52d5529b9d | 32 | |
HEPTA | 15:9c52d5529b9d | 33 | |
HEPTA | 15:9c52d5529b9d | 34 | |
HEPTA | 15:9c52d5529b9d | 35 | |
HEPTA | 15:9c52d5529b9d | 36 | wait(0.5); |
HEPTA | 15:9c52d5529b9d | 37 | } |
HEPTA | 15:9c52d5529b9d | 38 | } |
HEPTA | 15:9c52d5529b9d | 39 | xbee.initialize(); |
HEPTA | 15:9c52d5529b9d | 40 | } |
HEPTA | 15:9c52d5529b9d | 41 | } |
umeume | 2:1c5cdb2c3e0f | 42 | } |