Click“JavaScript" to view the corresponding JavaScript code: :
(6)Test Results:
Download code to micro:bit, keep USB cable connected, dial POWER switch
to ON end. The distance value will be displayed on monitor.
(How to quick download?)
① The "on start" command block runs only once to start the program.
②Serial redirection USB
③In the "forever" instruction block, the program runs cyclically.
④Serial write value distance=Ultrasonic
⑤ Delay time 200 milliseconds