Library and 'hello World' demo program for Seed Groove Ultrasonic distance meter. See also https://github.com/Seeed-Studio/Grove_Ultrasonic_Ranger/blob/master/Ultrasonic.h, http://www.seeedstudio.com/wiki/Grove_-_Ultrasonic_Ranger
Dependencies: Seed_Ultrasonic_Range mbed
main.cpp@0:8fa7c091d4de, 2014-11-01 (annotated)
- Committer:
- grassel
- Date:
- Sat Nov 01 20:47:28 2014 +0000
- Revision:
- 0:8fa7c091d4de
- Child:
- 1:9e37d8d9c360
tested to work with Seed Groove Ultrasonic sensor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
grassel | 0:8fa7c091d4de | 1 | #include "mbed.h" |
grassel | 0:8fa7c091d4de | 2 | #include "Ultrasonic.h" |
grassel | 0:8fa7c091d4de | 3 | |
grassel | 0:8fa7c091d4de | 4 | Ultrasonic u(p1); |
grassel | 0:8fa7c091d4de | 5 | |
grassel | 0:8fa7c091d4de | 6 | DigitalOut led(LED1); |
grassel | 0:8fa7c091d4de | 7 | |
grassel | 0:8fa7c091d4de | 8 | int main() { |
grassel | 0:8fa7c091d4de | 9 | long dist; |
grassel | 0:8fa7c091d4de | 10 | while(1) { |
grassel | 0:8fa7c091d4de | 11 | dist= u.measureInCentimeters(); |
grassel | 0:8fa7c091d4de | 12 | printf("measured distance %d cm\r\n", dist); |
grassel | 0:8fa7c091d4de | 13 | led = !led; |
grassel | 0:8fa7c091d4de | 14 | wait(1.0f); |
grassel | 0:8fa7c091d4de | 15 | } |
grassel | 0:8fa7c091d4de | 16 | } |