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.
source.cpp@0:01d408baf267, 2018-12-23 (annotated)
- Committer:
- corentinlenel
- Date:
- Sun Dec 23 18:08:03 2018 +0000
- Revision:
- 0:01d408baf267
Test du capteur de distance MS-EZ4.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| corentinlenel | 0:01d408baf267 | 1 | #include "header.h" |
| corentinlenel | 0:01d408baf267 | 2 | |
| corentinlenel | 0:01d408baf267 | 3 | AnalogIn sonar(p16); |
| corentinlenel | 0:01d408baf267 | 4 | BusOut leds(LED1, LED2, LED3, LED4); |
| corentinlenel | 0:01d408baf267 | 5 | |
| corentinlenel | 0:01d408baf267 | 6 | void test(void) |
| corentinlenel | 0:01d408baf267 | 7 | { |
| corentinlenel | 0:01d408baf267 | 8 | float mesure1, mesure2; |
| corentinlenel | 0:01d408baf267 | 9 | |
| corentinlenel | 0:01d408baf267 | 10 | mesure1 = sonar.read(); |
| corentinlenel | 0:01d408baf267 | 11 | wait(0.5); |
| corentinlenel | 0:01d408baf267 | 12 | mesure2 = sonar.read(); |
| corentinlenel | 0:01d408baf267 | 13 | |
| corentinlenel | 0:01d408baf267 | 14 | if (abs(mesure1 - mesure2) < 0.1f) |
| corentinlenel | 0:01d408baf267 | 15 | { |
| corentinlenel | 0:01d408baf267 | 16 | leds = 15; |
| corentinlenel | 0:01d408baf267 | 17 | } |
| corentinlenel | 0:01d408baf267 | 18 | else |
| corentinlenel | 0:01d408baf267 | 19 | { |
| corentinlenel | 0:01d408baf267 | 20 | leds = 0; |
| corentinlenel | 0:01d408baf267 | 21 | } |
| corentinlenel | 0:01d408baf267 | 22 | } |