Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: test_ultrasonic AEB Car_Simulator
Ultrasonic Class Reference
Ultrasonic Class This class is intended to be used with a ultrasonic sensor HC-SR04. More...
#include <Ultrasonic.h>
Public Member Functions | |
| Ultrasonic (PinName trigger, PinName echo) | |
| Constructor. | |
| int | read_cm () |
| Function to read the distance in cm. | |
Detailed Description
Ultrasonic Class This class is intended to be used with a ultrasonic sensor HC-SR04.
Once initialized the Ultrasonic object just call the read function to get the distance from object.
Definition at line 12 of file Ultrasonic.h.
Constructor & Destructor Documentation
| Ultrasonic | ( | PinName | trigger, |
| PinName | echo | ||
| ) |
Constructor.
- Note:
- This is used to initialize the ultrasonic object corresponding to one sensor, just pass as input the pin where the sensor is connected (they must be digital pins).
- Parameters:
-
trigger the trigger pin name echo the echo pin name
Definition at line 5 of file Ultrasonic.cpp.
Member Function Documentation
| int read_cm | ( | ) |
Function to read the distance in cm.
- Note:
- the distance is read internally every 60 ms so invoke this function not less than every 60 ms
- Returns:
- 0 if timeout(50ms) elapsed (error or out of range measure), 1-400 distance from object in cm
Definition at line 10 of file Ultrasonic.cpp.
Generated on Tue Jul 12 2022 20:50:40 by
1.7.2