智也 大野
/
mbed_ping
超音波センサー動作確認
main.cpp@0:f039b8066d21, 2017-03-17 (annotated)
- Committer:
- tomoya123
- Date:
- Fri Mar 17 08:44:31 2017 +0000
- Revision:
- 0:f039b8066d21
ultrasonic
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tomoya123 | 0:f039b8066d21 | 1 | #include "mbed.h" |
tomoya123 | 0:f039b8066d21 | 2 | #include "Ping.h" |
tomoya123 | 0:f039b8066d21 | 3 | |
tomoya123 | 0:f039b8066d21 | 4 | |
tomoya123 | 0:f039b8066d21 | 5 | Ping Pinger(p30); |
tomoya123 | 0:f039b8066d21 | 6 | |
tomoya123 | 0:f039b8066d21 | 7 | int main() { |
tomoya123 | 0:f039b8066d21 | 8 | float range; |
tomoya123 | 0:f039b8066d21 | 9 | |
tomoya123 | 0:f039b8066d21 | 10 | |
tomoya123 | 0:f039b8066d21 | 11 | while(1) { |
tomoya123 | 0:f039b8066d21 | 12 | Pinger.Send(); |
tomoya123 | 0:f039b8066d21 | 13 | wait_ms(30); |
tomoya123 | 0:f039b8066d21 | 14 | range = Pinger.Read_cm()/2.0; |
tomoya123 | 0:f039b8066d21 | 15 | wait(1.0); |
tomoya123 | 0:f039b8066d21 | 16 | printf("%0.1f\r\n",range); |
tomoya123 | 0:f039b8066d21 | 17 | } |
tomoya123 | 0:f039b8066d21 | 18 | } |