readUltrasonicDistance(id)
Reading ultrasonic sensor distance
Parameter
Parameters
Type
Description
id
unsigned char
ID number to be controlled, range 0 ~ 10
Return Values
Parameters
Type
Description
number
int
Ultrasonic distance, range 0 ~ 400cm
Example
Use the uKit Explore v2 board to display the distance read by ultrasonic sensor ID-1 every 400ms
Use the uKit Explore v2 board to read the ultrasonic sensor distance. When the distance is less than 5cm, set the on board LED to RED, and when the distance is more than 5cm, set the on board LED to GREEN.
Last updated