Program to test the ultrasonic sensor
Dependencies: Ultrasonic mbed
main.cpp
- Committer:
- AndreaAndreoli
- Date:
- 2016-06-02
- Revision:
- 0:349548d01ee3
- Child:
- 2:ba2b5acf0fdd
File content as of revision 0:349548d01ee3:
/* * An example showing how to use the Ultrasonic library */ #include "mbed.h" #include "Ultrasonic.h" DigitalOut led(LED_RED); Serial pc(USBTX, USBRX); // tx, rx int main() { Ultrasonic_init(); // Just call this funtion to initialize the ultrasonic sensor while (true) { led = !led; pc.printf("Distance: %f \n", read_cm()); // Call read_cm() to get the distance in cm wait(0.2); } }