![](/media/cache/profiles/2e74f94b232c5a0cc3e75b4eaaf64c90.jpg.50x50_q85.jpg)
Hepta communication
Dependencies: Hepta9axis HeptaBattery HeptaXbee mbed
Fork of Lab7-01_template by
main.cpp@13:75f99f3edf93, 2017-09-06 (annotated)
- Committer:
- HEPTA
- Date:
- Wed Sep 06 04:37:24 2017 +0000
- Revision:
- 13:75f99f3edf93
- Parent:
- 10:4d6870d0caa0
test
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); |
umeume | 2:1c5cdb2c3e0f | 7 | HeptaXbee xbee(p9,p10); |
HEPTA | 10:4d6870d0caa0 | 8 | Hepta9axis n_axis(p28,p27,0xD0,0x18); |
HEPTA | 13:75f99f3edf93 | 9 | HeptaBattery battery(p16,p26); |
umeume | 5:c5ccb1b07e8f | 10 | |
umeume | 2:1c5cdb2c3e0f | 11 | int main() |
umeume | 2:1c5cdb2c3e0f | 12 | { |
HEPTA | 13:75f99f3edf93 | 13 | int i = 0,rcmd=0,cmdflag=0; |
HEPTA | 13:75f99f3edf93 | 14 | float bt,ax,ay,az; |
HEPTA | 13:75f99f3edf93 | 15 | xbee.printf("Count Up!\r\n"); |
HEPTA | 13:75f99f3edf93 | 16 | while(1) { |
HEPTA | 13:75f99f3edf93 | 17 | xbee.printf("num = %d\r\n",i); |
HEPTA | 13:75f99f3edf93 | 18 | i++; |
HEPTA | 13:75f99f3edf93 | 19 | wait(1.0); |
HEPTA | 13:75f99f3edf93 | 20 | xbee.xbee_recieve(&rcmd,&cmdflag); |
HEPTA | 13:75f99f3edf93 | 21 | pc.printf("rcmd=%d, cmdflag=%d\r\n",rcmd, cmdflag); |
HEPTA | 13:75f99f3edf93 | 22 | if (cmdflag == 1) { |
HEPTA | 13:75f99f3edf93 | 23 | if (rcmd == 'a') { |
HEPTA | 13:75f99f3edf93 | 24 | pc.printf("Command Get %d\r\n",rcmd); |
HEPTA | 13:75f99f3edf93 | 25 | xbee.printf("HEPTA Uplink OK\r\n"); |
HEPTA | 13:75f99f3edf93 | 26 | pc.printf("===================\r\n"); |
HEPTA | 13:75f99f3edf93 | 27 | pc.printf("Accel sensing Mode\r\n"); |
HEPTA | 13:75f99f3edf93 | 28 | pc.printf("===================\r\n"); |
HEPTA | 13:75f99f3edf93 | 29 | for(int ii = 0; ii < 10; ii++) { |
HEPTA | 13:75f99f3edf93 | 30 | n_axis.sen_acc(&ax,&ay,&az); |
HEPTA | 13:75f99f3edf93 | 31 | battery.vol(&bt); |
HEPTA | 13:75f99f3edf93 | 32 | xbee.printf("AX = %f\r\n",ax); |
HEPTA | 13:75f99f3edf93 | 33 | xbee.printf("AY = %f\r\n",ay); |
HEPTA | 13:75f99f3edf93 | 34 | xbee.printf("AZ = %f\r\n",az); |
HEPTA | 13:75f99f3edf93 | 35 | xbee.printf("V = %f\r\n",bt); |
HEPTA | 13:75f99f3edf93 | 36 | wait(0.5); |
HEPTA | 13:75f99f3edf93 | 37 | } |
HEPTA | 13:75f99f3edf93 | 38 | } |
HEPTA | 13:75f99f3edf93 | 39 | xbee.initialize(); |
HEPTA | 13:75f99f3edf93 | 40 | } |
HEPTA | 13:75f99f3edf93 | 41 | } |
umeume | 2:1c5cdb2c3e0f | 42 | } |