Etienne Stransky
/
Tests_detecteur_ultrasons
ok
Revision 0:22ab0837ece5, committed 2019-02-12
- Comitter:
- stersky
- Date:
- Tue Feb 12 14:50:38 2019 +0000
- Commit message:
- ok
Changed in this revision
main.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 |
diff -r 000000000000 -r 22ab0837ece5 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Feb 12 14:50:38 2019 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); //Initialise une liason série via le connecteur USB du pc +I2C ultrason(p9,p10); //Initialise une connexion i2c sur p9 et p10 + +int main() +{ + +int adresse=0xE0 ; +ultrason.frequency(50000); +pc.baud(115200);//Initialise la vitesse de la communication série + +char config[2]; char lecture[2]; int mesure = 5; + +while(1) { +config[0]= 0x00; +config[1]= 0x51; +ultrason.write(adresse, config, 2); + +wait_ms(100); + +config[0]= 0x02; +ultrason.write(adresse, config, 1); + +ultrason.read(adresse, lecture, 2); + + +pc.printf("Distance : %d cm\n\r",lecture[1]); + +} + +}
diff -r 000000000000 -r 22ab0837ece5 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Feb 12 14:50:38 2019 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file