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
Revision 3:0e5ce872c9fd, committed 2020-02-04
- Comitter:
- Tredelnic
- Date:
- Tue Feb 04 13:53:22 2020 +0000
- Parent:
- 2:d8a097fb2022
- Commit message:
- Ajout de fonction
Changed in this revision
Bluetooth.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- a/Bluetooth.cpp Mon Feb 03 13:34:35 2020 +0000 +++ b/Bluetooth.cpp Tue Feb 04 13:53:22 2020 +0000 @@ -2,61 +2,90 @@ #include <stdio.h> DigitalOut LED(LED1); + Serial HC06(D1,D0); //TX - RX du microcontroler Serial pc(USBTX, USBRX); +PwmOut Mot_G(D12); +PwmOut Mot_D(D10); + +DigitalOut SensMotG(D11); +DigitalOut SensMotD(D9); + + + struct Trame { - int kp; - int kd; - int val3; - int val4; - int val5; - int val6; - int val7; + float kp; + float kd; + float val3; + float val4; + float val5; + float val6; + float val7; }; +Trame trame; + + +void Init(void) +{ + + Mot_D.period_us(40); + Mot_G.period_us(40); + + SensMotD = 1; + SensMotG = 1; + Mot_G.write(0.5); + Mot_D.write(0.5); + +} + + +void ReceptionBluetooth(void) +{ + + int i=0; + char val[500]; + + val[0]= HC06.getc(); + + while(val[i]!='\n') { + i++; + val[i]= HC06.getc(); + } + + int error = sscanf(val,"%f:%f:%f:%f:%f:%f:%f", + &trame.kp, + &trame.kd, + &trame.val3, + &trame.val4, + &trame.val5, + &trame.val6, + &trame.val7); + +} + int main() { HC06.baud(9600); pc.baud (115200); - Trame trame; + while (1) { - /* char info = HC06.getc(); - if (info=='a') LED = 1; - else if (info=='b') LED =0; - */ - int i=0; - char val[500]; - - val[0]= HC06.getc(); - - while(val[i]!='\n') { - i++; - val[i]= HC06.getc(); - //printf("%c",val[i]); - } - - int error = sscanf(val,"%d.%d.%d.%d.%d.%d.%d", - &trame.kp, - &trame.kd, - &trame.val3, - &trame.val4, - &trame.val5, - &trame.val6, - &trame.val7); - - pc.printf("\r\nkp %d kd %d val3 %d val4 %d val5 %d val6 %d val7 %d", - trame.kp, - trame.kd, - trame.val3, - trame.val4, - trame.val5, - trame.val6, - trame.val7); + /* pc.printf("\r\nkp %f kd %f val3 %f val4 %f val5 %f val6 %f val7 %f", + trame.kp, + trame.kd, + trame.val3, + trame.val4, + trame.val5, + trame.val6, + trame.val7); + */ + ReceptionBluetooth(); + Init(); } }
--- a/mbed.bld Mon Feb 03 13:34:35 2020 +0000 +++ b/mbed.bld Tue Feb 04 13:53:22 2020 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/235179ab3f27 \ No newline at end of file