INTRODUCTION

In the previous lessons, we introduced the ultrasonic obstacle avoidance robot and infrared obstacle avoidance ro. In order to avoid obstacles more accurately, in this lesson we combined an ultrasonic module and an infrared obstacle detector sensor to build an obstacle avoidance robot.

PREPARATION

Hardware:

● 1 X USB cable

● 1 X micro:bit robot

CODE PROGRAM

Then the micro:bit is connected to the computer through USB, and the computer will pop up a U disk and click the URL in the U disk to enter the programming interface. Input this URL https://github.com/osoyoo/OSOYOO-MICRO-BIT-CAR to get the package.

RUNNING RESULT

When the front obstacle distance measured by ultrasonic sensor is greater than 15cm.

When the front obstacle distance measured by ultrasonic sensor is less than or equal to 15cm.

Note:

This experiment must be carried out indoors to reduce interference from sunlight to infrared receiver.

If the robot tracking is not normal, you can adjust its speed and running time through makecode, and you can also change the sensitivity of the infrared obstacle avoidance sensor by adjusting the potentiometer