Skip to main content

Case 21: Motorcycle Robot

Case Introduction

Use Nezha Pro Sport Kit to build a two-wheeled motorcycle robot, adopting the classic layout of rear-wheel motor drive + front-wheel steering gear to simulate the movement logic of a real motorcycle. By programming to control the motor speed and steering gear angle, basic functions such as forward movement, steering, and speed regulation are realized, helping learners understand the mechanical linkage principle of "power system + steering system", master the basic control methods of motors and steering gears, and experience the complete engineering process from mechanical construction to programming and debugging.

Teaching Preparation

NameGraphic
Nezha Pro Sport Kit

Teaching objectives

Mechanical transmission: Understand the motorcycle movement principle of "rear-wheel drive + front-wheel steering" and master the mechanical installation method of motors and servos.

Control technology: Learn to set the motor speed (PWM adjustment) and servo angle through programming to achieve straight-line driving and steering operations.

Programming logic: Master the control process of "input command → main control board processing → actuator action" and understand the application of conditional statements (such as if) in motion control.

Interdisciplinary integration: Combine physics (gear transmission ratio), engineering (structural stability), and programming (modular control) knowledge to cultivate system integration capabilities.

Course introduction

How does the referee judge the goal in a basketball game? If you practice by yourself, how can you quickly know how many goals you have scored?

Can the basket "count" the number of goals by itself? Scene introduction: "Today we are going to equip the basket with an 'intelligent brain'! When the basketball passes through the basket, the collision sensor will immediately 'see' the goal like a referee, and the main control board will immediately record the number and display it on the screen. Whether you are practicing shooting or competing with classmates, this counter allows you to focus on sports and let technology handle the data!"

Learning and Exploration

Explore the relationship between motor speed and robot driving speed, analyze the influence of steering angle of servo on turning radius, and study how to improve driving stability by adjusting the front and rear wheelbase.

Building steps

Hardware connection

Connect the two smart motors to the M1 and M4 ports of the Nezha Pro expansion board respectively.

Code Programming

Go to "makecode.microbit.org" and click New Project.

Enter a project name in the pop-up window and click Create.

Click Extension in the code drawer.

In the pop-up interface, enter nezha pro and click the search icon. Click it when the nezha pro software library is displayed. Load the PlanetX software library in the same way.

Sample Program

Program link: https://makecode.microbit.org/_L6k80WEzcUCz

You can also download the program directly from the following webpage.

Download Program

Connect PC and micro:bit V2 with USB cable.

After the connection is successful, a drive named MICROBIT will be recognized on the computer.

Click in the lower left corner and select Connect Device.

Click

Click

In the pop-up window, select BBC micro:bit CMSIS-DAP, and then select Connect. At this point, our micro:bit has been successfully connected.

Click Download the program

Case demonstration

Press button A to move the motorcycle forward, and press button B to stop.

Summary and sharing

Extended knowledge

Physics knowledge in motorcycle sports Steering geometry: The intersection of the front wheel steering axis and the ground must be located inside the tire contact point (Ackerman steering principle) to reduce tire slip during steering. This case simulates this feature through the connecting rod length. Inertia effect: Sudden steering at high speed may cause rollover due to centrifugal force, and stability can be improved by lowering the center of gravity (adding chassis counterweights).