readInfraredDistance(id)
Get infrared sensor distance value.
Parameter
Parameters | Type | Description |
id | unsigned char | ID number to be controlled, range 0 ~ 10 |
Return Values
Parameters | Type | Description |
number | int | Distance, range 0 ~ 20cm |
Example
Use the uKit Explore v2 board to display the distance read by infrared sensor ID-1 every 400ms
Use the uKit Explore v2 board to read the infrared 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