coucou
Dependencies: HC_SR04_Ultrasonic_Library mbed
main.cpp@0:5fba740a37eb, 2016-09-28 (annotated)
- Committer:
- mathieusab
- Date:
- Wed Sep 28 14:16:26 2016 +0000
- Revision:
- 0:5fba740a37eb
- Child:
- 1:3bad1115bf14
coucou
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mathieusab | 0:5fba740a37eb | 1 | #include "mbed.h" |
mathieusab | 0:5fba740a37eb | 2 | #include "ultrasonic.h" |
mathieusab | 0:5fba740a37eb | 3 | |
mathieusab | 0:5fba740a37eb | 4 | |
mathieusab | 0:5fba740a37eb | 5 | PinName trig = PA_10; |
mathieusab | 0:5fba740a37eb | 6 | PinName echo = PA_9; |
mathieusab | 0:5fba740a37eb | 7 | float updateSpeed = 1; // 1 Hz, 1 fois par sec |
mathieusab | 0:5fba740a37eb | 8 | float timeout = 2; |
mathieusab | 0:5fba740a37eb | 9 | |
mathieusab | 0:5fba740a37eb | 10 | |
mathieusab | 0:5fba740a37eb | 11 | int mesure = 0; |
mathieusab | 0:5fba740a37eb | 12 | |
mathieusab | 0:5fba740a37eb | 13 | int main() |
mathieusab | 0:5fba740a37eb | 14 | { |
mathieusab | 0:5fba740a37eb | 15 | |
mathieusab | 0:5fba740a37eb | 16 | ultrasonic(trig, echo, updateSpeed, timeout); |
mathieusab | 0:5fba740a37eb | 17 | |
mathieusab | 0:5fba740a37eb | 18 | while(1) |
mathieusab | 0:5fba740a37eb | 19 | { |
mathieusab | 0:5fba740a37eb | 20 | mesure = getCurrentDistance(); |
mathieusab | 0:5fba740a37eb | 21 | wait(0.1); |
mathieusab | 0:5fba740a37eb | 22 | printf("%d\n",mesure); |
mathieusab | 0:5fba740a37eb | 23 | wait(0.1); |
mathieusab | 0:5fba740a37eb | 24 | } |
mathieusab | 0:5fba740a37eb | 25 | } |