easy xbee controller

Dependencies:   MultiSerial mbed

Committer:
Hatter
Date:
Thu Sep 04 04:52:34 2014 +0000
Revision:
0:a5b0ad1cf314
Child:
1:5c6ec036268e
?????????;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Hatter 0:a5b0ad1cf314 1 //簡易コントローラー
Hatter 0:a5b0ad1cf314 2
Hatter 0:a5b0ad1cf314 3 #include "mbed.h"
Hatter 0:a5b0ad1cf314 4 #include "MultiSerial.h"
Hatter 0:a5b0ad1cf314 5
Hatter 0:a5b0ad1cf314 6 #define KEYCODE 0xAA
Hatter 0:a5b0ad1cf314 7
Hatter 0:a5b0ad1cf314 8 MultiSerial xbee(p28, p27,write);
Hatter 0:a5b0ad1cf314 9 Serial pc(USBTX,USBRX);
Hatter 0:a5b0ad1cf314 10
Hatter 0:a5b0ad1cf314 11 BusIn sw(p5,p6,p7,p8,p9,p10,p11,p12);
Hatter 0:a5b0ad1cf314 12
Hatter 0:a5b0ad1cf314 13 BusOut check(LED1,LED2,LED3,LED4);
Hatter 0:a5b0ad1cf314 14
Hatter 0:a5b0ad1cf314 15 uint8_t value[2]={0};
Hatter 0:a5b0ad1cf314 16 uint8_t convert;
Hatter 0:a5b0ad1cf314 17
Hatter 0:a5b0ad1cf314 18 int main(){
Hatter 0:a5b0ad1cf314 19
Hatter 0:a5b0ad1cf314 20 xbee.write_data(value,KEYCODE);
Hatter 0:a5b0ad1cf314 21
Hatter 0:a5b0ad1cf314 22 for(;;){
Hatter 0:a5b0ad1cf314 23
Hatter 0:a5b0ad1cf314 24 sw.mode(PullUp);
Hatter 0:a5b0ad1cf314 25
Hatter 0:a5b0ad1cf314 26 convert = ~sw;
Hatter 0:a5b0ad1cf314 27
Hatter 0:a5b0ad1cf314 28 value[0] = convert&0x0F;
Hatter 0:a5b0ad1cf314 29 value[1] = (convert&0xF0)>>4;
Hatter 0:a5b0ad1cf314 30
Hatter 0:a5b0ad1cf314 31 check = value[0];
Hatter 0:a5b0ad1cf314 32
Hatter 0:a5b0ad1cf314 33 }
Hatter 0:a5b0ad1cf314 34 }