INTRODUCTION

What we will learn in this lesson is robot following. We can use infrared obstacle avoidance sensor to achieve robot following, or we can use ultrasonic sensor to achieve it. In this lesson, we learn to follow the ultrasonic following. Ultrasonic following can realize that if the robot has an object in front of the ultrasonic sensor, the robot will follow. If there is no object in front of the ultrasonic sensor, the robot will stop.

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

Send well the test code to micro:bit main board, then insert the micro:bit main board into the robot, and connect a 9v battery into the battery box.

If the robot has an object in front of the ultrasonic sensor, the robot will follow. If there is no object in front of the ultrasonic sensor, the robot will stop.