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@1:9e37d8d9c360, 2014-11-01 (annotated)
- Committer:
- grassel
- Date:
- Sat Nov 01 20:50:18 2014 +0000
- Revision:
- 1:9e37d8d9c360
- Parent:
- 0:8fa7c091d4de
updated copyright header to note my port to mbed
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 | 1:9e37d8d9c360 | 4 | Ultrasonic u(p1); // this must be a pin suitable for DigitalInOut |
grassel | 0:8fa7c091d4de | 5 | DigitalOut led(LED1); |
grassel | 0:8fa7c091d4de | 6 | |
grassel | 0:8fa7c091d4de | 7 | int main() { |
grassel | 0:8fa7c091d4de | 8 | long dist; |
grassel | 0:8fa7c091d4de | 9 | while(1) { |
grassel | 0:8fa7c091d4de | 10 | dist= u.measureInCentimeters(); |
grassel | 0:8fa7c091d4de | 11 | printf("measured distance %d cm\r\n", dist); |
grassel | 0:8fa7c091d4de | 12 | led = !led; |
grassel | 0:8fa7c091d4de | 13 | wait(1.0f); |
grassel | 0:8fa7c091d4de | 14 | } |
grassel | 0:8fa7c091d4de | 15 | } |