- It measures the distance from the object to ultrasonic sensor.
- It displays the distance graphically on the screen.
- If the object is close to the sensor, displays will draw red line.
- If the object is far or if there is nothing in front of the sensor, the display will draw blue lines.
To create a display that shows the position of the object and distance, I have to draw on a gray background coordinate system quarters.
Function drawRadar(); draws white lines that represent the coordinate system.
This is translated with the center for 700px x and y axes.
After switching on this function the display looks like this:
- drawObject(); function draws a red line if the object is close to the sensor.
- drawLine(); function draws a blue line if the object is far.
- drawText(); function prints text on the screen.