Some users may have the issue that the robot fails to avoid obstacle as it should be, then after checking firmware information, connection and other factors, it is necessary to check whether the ultrasonic sensor is still working fine. Here I’ll include three methods to test the ultrasonic sensors, with mBlock 3 software, mBlock 5 software and Arduino IDE. By the way, here I take mCore (mBot) as an example.
Test with mBlock 3. You can download here and install this software:
Once installed, please upgrade firmware for the mBot first (refer to mBot FAQ1)
Then run below online codes:
Test with Arduino IDE. In mBlock 3, you can drag mBot program, the right click on it, choose “upload to arduino”:
Then it shows below picture, please choose edit with arduino ide:
Then go to files->examples->makeblockdrive->meultrasonicsensor->ultrasonic sensor test->open it:
Then choose board and port under tools:
If you have mBot, choose Arduino/genuino uno. Also change the codes as below:
Then press upload icon:
Once upload, choose the serial port monitor:
Then we’ll see below:
- Test with mBlock 5 the one that you installed.
Connect USB from mbot to computer with USB cable, then update firmware:
Then code like below: (you need variable)
Or go to Sprite, code like this: