Building a car using radio communication between two Micro:bit boards

Micro:bit 22-11-26
121 0

Tutorial plan

1- Objective of the project

2- Required Components

3- Circuit Connections of system

4- Makecode program for Micro:bit boards

 

 

Objective of the project

This project involves building a four-wheel robotic car controlled remotely using two Micro:bit boards communicating through radio waves.

The first Micro:bit acts as a transmitter and uses its built-in accelerometer to detect the board's inclination and movements. By tilting the Micro:bit in different directions, the user can send wireless commands to control the car's movements.

The second Micro:bit, installed on the car, acts as a receiver. It receives and interprets the transmitted commands, then controls the four motors through a motor driver expansion board.

The car can move forward, backward, turn left, turn right, and stop according to the inclination of the sender Micro:bit.

This project introduces students to wireless communication, accelerometer sensors, embedded systems, and robotics programming using Microsoft MakeCode.

 

Required Components

1. Sender Micro:bit Board

The Sender Micro:bit acts as a remote controller. Its built-in accelerometer detects the board's inclination (forward, backward, left, or right) and sends the corresponding movement commands wirelessly using radio communication.

2. Receiver Micro:bit Board

The Receiver Micro:bit is installed on the robotic car and receives the radio commands sent by the sender board. It processes these commands and sends the appropriate control signals to the Driver Expansion Board to operate the four motors.

2. Driver Expansion Board

The Driver Expansion Board is used to connect the Micro:bit to the car's motors and control their operation. It receives commands from the Micro:bit and controls the speed and direction of rotation of the four DC motors.

3. Four-Wheeled Car Chassis

The four-wheeled car chassis provides the mechanical structure of the robot. It consists of four DC motors, four wheels, and a supporting frame. The motors allow the car to move forward, backward, turn left, and turn right.

4. Jumper Wires

Jumper wires

Jumper wires are used to make the electrical connections between the Micro:bit, the GPIO expansion board and the servo motor.

5. Two 3.7V Rechargeable Batteries

The two 3.7V rechargeable batteries provide the electrical power required to operate the robotic car. They supply energy to the Driver Expansion Board and the four DC motors, allowing the car to move autonomously according to the commands received from the sender Micro:bit.

Circuit Connections of system

 

To assemble the robotic car, follow these steps:

1. Micro:bit Receiver: Insert the receiver Micro:bit into the dedicated connector on the Driver Expansion Board, ensuring that it is correctly positioned.

2. DC Motors: Connect the four DC motors to the motor output terminals (M1, M2, M3 and M4) of the Driver Expansion Board. These motors control the rotation of the four wheels.

3. Power Supply: Connect the two 3.7V rechargeable batteries to the power input of the Driver Expansion Board, respecting the positive (+) and negative (−) terminals.

4. Car Chassis: Fix the four motors and wheels to the chassis, then secure the Driver Expansion Board and battery holder onto the car.

5. Final Check: Verify all electrical connections, battery polarity and mechanical assembly before switching on the car.

 

MakeCode Program for the Micro:bit Boards

Configuring Radio Communication and Adding the Motor Control Extension in MakeCode for Micro:bit

1- Go to Microsoft MakeCode and start a new project.

2- In MakeCode, open the Blocks Editor (https://makecode.microbit.org/).

3. Selecting the Radio Category :

In the Send section, the radio send string block allows the sender Micro:bit to transmit text messages (commands) to the receiver Micro:bit. These messages are used to control the movements of the robotic car.

In the Send section, the radio send string block allows the sender Micro:bit to transmit text messages (commands) to the receiver Micro:bit. These messages are used to control the movements of the robotic car.

In the Radio category, the Receive section provides blocks that allow the receiver Micro:bit to process incoming messages.

Select the on radio received receivedString block to detect and retrieve text messages sent by the sender Micro:bit. The received string can then be used to determine the appropriate movement of the car.

4. Selecting the Shake Event

In the Input category, click on more to display additional input blocks.

Select the on shake block to detect when the sender Micro:bit is shaken. This event can be used to trigger a specific action or send a command through radio communication.

5. Opening the Extensions Library

Click on Extensions at the bottom of the MakeCode toolbox to access additional programming libraries.

5. Installing the DFROBOT Motor Extension 

In the Extensions search field, enter the following GitHub address: https://github.com/DFRobot/pxt-motor

Select the motor extension to add the DFRobot motor-control library to the MakeCode environment.

This extension provides programming blocks for controlling DC motors, stepper motors and servos.

6. Using the DF-Driver Category

After installing the extension, a new category named DF-Driver appears in the MakeCode toolbox.

For this project, the Motor block is particularly important because it allows the receiver Micro:bit to control the four DC motors connected to the Driver Expansion Board.

 

Wireless Robot Control Using Radio Communication in MakeCode

1. Radio Transmitter Program

The radio transmitter program developed using Microsoft MakeCode. It allows a robot to be controlled wirelessly through the movement of a micro:bit device. The program uses different movement events to send commands through radio communication.

- Forward Movement : when the micro:bit logo is moved up, the program displays a North arrow and sends the string "forward" through the radio. After a delay of 2000 milliseconds, it sends a "stop" command.

- Backward Movement : when the micro:bit logo is moved down, the program displays a South arrow and transmits the string "backward". After 2000 milliseconds, it sends a "stop" command.

- Left Movement : when the micro:bit is tilted to the left, the program displays a West arrow and sends the string "left" to the receiver. After a 2000-millisecond delay, it transmits the "stop" command.

- Right Movement : when the micro:bit is tilted to the right, the program displays an East arrow and sends the string "right". After 2000 milliseconds, it sends a "stop" command.

2. Radio Receiver and Motor Control Program

The radio receiver program is responsible for receiving commands sent by the transmitter and controlling the robot's four motors. The program uses the on radio received event to receive a string called receivedString. It then checks the received command using conditional statements (if) and activates the motors according to the requested direction.

- Forward Movement : when the received string is "forward", all four motors (M1, M2, M3, and M4) rotate clockwise (CW) at speed 70. This makes the robot move forward.

- Backward Movement : when the received string is "backward", all four motors rotate counterclockwise (CCW) at speed 70. This makes the robot move backward.

- Right Movement : when the received string is "right", motors M1, M2, and M3 rotate clockwise, while motor M4 rotates counterclockwise. This combination allows the robot to turn right.

- Left Movement : When the received string is "left", motors M1 and M3 rotate counterclockwise, while motors M2 and M4 rotate clockwise. This combination allows the robot to turn left.

- Stop Movement : When the received string is "stop", the Motor Stop All command is executed, stopping all four motors and bringing the robot to a complete stop.

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

Pictures of the articles

Robotic site created by Mohamed Ali Haj Salah - Teacher info