![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This consists of the transmitter code to send characters wirelessly using the Zigbee protocol.
Fork of Xbee_transmitter by
Revision 1:004033e7a7c7, committed 2015-06-04
- Comitter:
- anthony25
- Date:
- Thu Jun 04 08:36:47 2015 +0000
- Parent:
- 0:e7abcef0b57f
- Commit message:
- mbed transmission
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Dec 07 07:29:32 2012 +0000 +++ b/main.cpp Thu Jun 04 08:36:47 2015 +0000 @@ -9,7 +9,7 @@ Serial pc(USBTX, USBRX); Serial xbee1(p9,p10); -DigitalOut rst1(p11); //Digital reset for the XBee, 200ns for reset +DigitalOut rst1(p8); //Digital reset for the XBee, 200ns for reset DigitalOut myled(LED1);//Create variable for Led 3 on the mbed @@ -17,28 +17,67 @@ int main() { int character; + char diz_deg; + char deg; + char force_appl; + char Val_capt1; + char Val_capt2; + char Val_capt3; + char Val_capt4; + char Val_capt5; + char Val_capt6; + char Val_capt7; + char Val_capt8; + char Val_capt9; + xbee1.baud(9600); char buffer[20]; rst1 = 0; //Set reset pin to 0 - myled = 0;//Set LED3 to 0 + myled = 1;//Set LED3 to 0 wait_ms(1);//Wait at least one millisecond rst1 = 1;//Set reset pin to 1 wait_ms(1);//Wait another millisecond - - while (1) + diz_deg='2'; + deg='5'; + force_appl='12'; + Val_capt1='7'; + Val_capt2='12'; + Val_capt3='15'; + Val_capt4='9'; + Val_capt5='5'; + Val_capt6='12'; + Val_capt7='14'; + Val_capt8='25'; + Val_capt9='3'; +//xbee1.printf("%x%c",2,deg); + // pc.printf("%x %c %c %c %c %c %c %c %c %c %c %c %x\n", 2,diz_deg,deg,force_appl,Val_capt1, Val_capt2, Val_capt3,Val_capt4, Val_capt5,Val_capt6,Val_capt7,Val_capt8,Val_capt9,3); + xbee1.printf("%c$%c$%c$%c$%c$%c$%c$%c$%c$%c$%c$%c$%x\n", 0x41,diz_deg,deg,force_appl,Val_capt1, Val_capt2, Val_capt3,Val_capt4, Val_capt5,Val_capt6,Val_capt7,Val_capt8,Val_capt9,3); + while (1) { - { - if(pc.readable()) { - //pc.gets(buffer,10); - //xbee1.putc(buffer); //XBee write whatever the PC is sending + if(pc.readable()) { /// ? caractère sur la liaison série du xbee sur mbed + character = pc.getc();; // on lit le caractère arrivé sur le PC + // xbee1.putc(buffer); //XBee write whatever the PC is sending + xbee1.printf("%c$%c$%c$%c$%c$%c$%c$%c$%c$%c$%c$%c$%c\n", 0x02,diz_deg,deg,force_appl,Val_capt1, Val_capt2, Val_capt3,Val_capt4, Val_capt5,Val_capt6,Val_capt7,Val_capt8,Val_capt9,0x03); myled = !myled; - character = pc.getc(); - xbee1.putc(character); - pc.putc(character); + xbee1.putc(character); // on lit le caractère et on le met dans variable charactere + + + //xbee1.putc(character); + // pc.putc(character); // on envoit le caractere recu sur l'usb pour visualiser sur teraterm + + } + + if(xbee1.readable()) { /// ? caractère sur la liaison série du xbee sur mbed + // pc.gets(buffer,10); + // xbee1.putc(buffer); //XBee write whatever the PC is sending + myled = !myled; + character = xbee1.getc(); // on lit le caractère et on le met dans variable charactere + //xbee1.putc(character); + pc.putc(character); // on envoit le caractere recu sur l'usb pour visualiser sur teraterm } //pc.printf("I got %s on sending side \n", buffer); - wait(.1); + } -} \ No newline at end of file +}