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-os nRF24L01P
Diff: main.cpp
- Revision:
- 10:0312e23ba3a1
- Parent:
- 9:67d737d8a349
- Child:
- 12:1378fba9c916
--- a/main.cpp Fri Feb 25 10:13:06 2022 +0000 +++ b/main.cpp Fri Mar 11 08:08:30 2022 +0000 @@ -29,8 +29,12 @@ #define TRANSFER_SIZE 12 char chaine[50]; - float reception[3]; - float Vavance, Vlat,Wz; + char tampon; + + char* reception8; + int16_t reception16[TRANSFER_SIZE/2]; + reception8 = (char*) reception16; + int16_t Vavance, Vlat,Wz; int i; my_nrf24l01p.powerUp(); my_nrf24l01p.setRfFrequency(2420); @@ -40,24 +44,32 @@ my_nrf24l01p.setCrcWidth(0); my_nrf24l01p.setRxAddress(); my_nrf24l01p.enable(); + pc_serie.write("Je suis le robot de Eve", strlen("Je suis le robot de Eve")); maled2 = 1; + MX12 servo_bus(PC_4, PC_5, 115200); while (1) { if (my_nrf24l01p.readable()) { maled2 = !maled2; - my_nrf24l01p.read( NRF24L01P_PIPE_P0, (char *)reception, TRANSFER_SIZE ); - Vavance = reception[0]; - Vlat = reception[1]; - Wz = reception[2]; + my_nrf24l01p.read( NRF24L01P_PIPE_P0, reception8, TRANSFER_SIZE ); + for (i=0 ; i<TRANSFER_SIZE;i+=2){ + tampon = reception8[i+1]; + reception8[i+1] = reception8 [i]; + reception8[i]= tampon; + } + + Vavance = reception16[0]; + Vlat = reception16[1]; + Wz = reception16[2]; - sprintf(chaine," Vav = %f, Vlat = %f, Wz = %f\n\r",(float)Vavance, (float)Vlat, (float)Wz); + sprintf(chaine," Vav = %d, Vlat = %d, Wz = %d\n\r",(int)Vavance, (int)Vlat, (int)Wz); pc_serie.write(chaine, strlen(chaine)); - // cmd_moteur(Vavance, Vlat, Wz); + servo_bus.cmd_moteur(Vavance/1000.0, Vlat/1000.0, Wz); }