The micro:bit Vehicle Voice Control System is an innovative voice-controlled car project based on the micro:bit development board. This system combines voice recognition technology with the fun-filled Maqueen Plus car, providing users with a new and intuitive interactive experience.
The core of the system is a voice recognition sensor that can be used with micro:bit. It can receive and recognize user voice commands, then convert these commands into signals to control the car's(Maqueen Plus V2) movement. This design allows users to control the car's forward, backward, left turn, right turn movements through voice commands, and even perform more complex operations, such as controlling the gripper(gripper is also known as micro:Maqueen Mechanic - Beetle), or turning the car lights on or off.
Task Objective
By utilizing the micro:bit main controller and the voice recognition sensor, we can achieve voice control over the Maqueen Plus car. This includes basic operations such as moving forward, moving backward, turning left, turning right, turning on the car lights, turning off the car lights, and opening or closing the gripper.
Software Preparation
Makecode Programming Software:microsoft MakeCode for micro:bit
Voice Recognition Plugin:https://github.com/DFRobot/pxt-DFRobot_voiceRecognition.git
Maqueen Plus V2 Plugin:https://github.com/DFRobot/pxt-DFRobot_MaqueenPlus_v20
Hands-on Practice
This project mainly controls the forward, backward, left, and right movements of the car through fixed voice command words, and uses fixed voice command words to control the corresponding operations of the car lights and gripper on the car. Therefore, it is implemented in the following two tasks.
Task Description 1: Voice-Driven Car System
Control the car to move forward for 1 second, move backward for 1 second, turn left by 45 degrees, and turn right by 45 degrees through fixed command words such as 'Go forward', 'Retreat', 'Turn left forty-five degrees', and 'Turn right forty-five degrees'.
Task Description 2: Voice-Controlled Car Lights and gripper System
Control the car lights to turn on or off through fixed command words such as 'Turn on the light' and 'Turn off the light'. Control the car gripper to open or close through fixed command words such as 'Set servo to ninety degrees' and 'Set servo to thirty degrees'.
Task Description 1: Voice-Driven Car System
1. Hardware Connection
Using screws and nuts, install the voice recognition sensor on the Maqueen Plus. The specific installation method is as follows: After the installation is complete, connect the voice recognition module to the I2C interface of the car, switch the communication switch on the voice recognition module to the I2C end, and switch the speaker switch to the SPK1 end.
2. Makecode Software Preparation
Create a new project: Copy the MakeCode URL "Microsoft MakeCode for micro:bit," open it in your browser, click on "New Project," modify the project name to "micro:bit Vehicle Voice Control System" and then click "Create."
Add Voice Recognition Extension: After successfully creating the project, enter the programming interface. Click on 'Extensions' in the command area, enter the extension link 'https://github.com/DFRobot/pxt-DFRobot_voiceRecognition.git' in the search bar, click 'Search', find the 'voiceRecognition' extension and click on it, completing the addition of the extension.
Add Maqueen Plus Extension: Click on 'Extensions' in the command area, enter the extension link 'https://github.com/DFRobot/pxt-DFRobot_MaqueenPlus_v20' in the search bar, click 'Search', find the 'MaqueenPlus' extension and click on it, completing the addition of the extension.
5. Makecode program coding
To control the Maqueen Plus car through voice commands, first, in the 'on start' program, use the 'initialize via I2C until successful' command to initialize the car.
After the voice recognition sensor is connected to the I2C interface of the car, how can it be used? Similarly, in the 'on start' program, initialize the voice recognition module, set the volume to 4, the wake-up duration to 20 seconds, and the wake-up word to 'hello Robot'.
After the initialization operation is completed, in the 'forever' command, use the 'identify once and save the results' command to recognize and save what we say to the voice recognition sensor.
In this project, the fixed command words of the voice recognition sensor are mainly used to move forward, move backward, turn left 45 degrees, and turn right 45 degrees, to control the car to perform the specified actions. The correspondence table between the fixed command words and the car's operation is as follows:
Next, use the conditional statement 'if...then' and the 'recognize it? ' command to determine whether an audio command has been detected. After recognizing the voice command word, it is necessary to use a conditional statement to judge whether the recognition result is a fixed command word. Use the comparison operator '=' command to compare the 'get the result' command with the 'Fixed command Words Go forward ID' command in the table.
If the condition is true, control the car to move forward for 1 second and then stop. To move forward, use the 'set all motor direction rotate forward speed 100' command to set both motors of the car to rotate forward. Use the 'pause (ms) 1000' command to set the car to move forward for 1 second, and then use the 'set all motor stop' command to control the car to stop.
For the car to move backward for 1 second, turn left 45 degrees, and turn right 45 degrees, you can use a similar method.
3. Makecode complete program
Makecode Complete program link:https://makecode.microbit.org/_fbaRxoPD1Ud8
The Makecode complete program is as follows:
4. Running the Program
Click 'Download'. After the program is successfully downloaded, plug the micro:bit into the main control expansion board of Maqueen Plus, and turn on the power switch of the car. Next, you can wake up the voice module with the wake-up word 'Hello Robot', and then control the car to move forward, backward, turn left 45 degrees, and turn right 45 degrees with fixed voice commands.
Task Description 2: Voice-Controlled Car Lights and gripper System
1. Hardware Connection
Use two 1.5cm copper columns to install the holder at the front of the car, and connect the servo to the P0 interface of the car.
Note: For the method of installing the gripper, click to view the installation tutorial.
2. Makecode program coding
This task mainly uses the fixed command words "Turn on the light", "Turn off the light" to control the opening and closing of the car lights, and uses the fixed command words "Set servo to ninety degrees", "Set servo to thirty degrees" to control the opening and closing of the holder. The table of fixed command words and car operation is as follows:
Next, based on the foundation of Task One, we will complete the control of the car lights and the opening and closing of the holder using voice command words. Using the conditional judgment statement 'if...then', we will compare the 'get the result' command with the 'Fixed command Words Turn on the light ID' command from the table.
When the condition is true, use the 'control all led light open' command to turn on all the lights on the car.
When the 'get the result' command matches the 'Fixed command Words Turn on the light ID' command, use the 'control all led light close' command to turn off all the lights on the car.
When the 'get the result' command matches the 'Fixed command Words Set servo to ninety degrees ID' command, use the 'servo write pin P0 to 90' command to control the servo of the gripper to rotate to 90 degrees (gripper closed).
When the 'get the result' command matches the 'Fixed command Words Set servo to thirty degrees ID' command, use the 'servo write pin P0 to 30' command to control the servo of the gripper to rotate to 30 degrees (gripper open).
3. Makecode complete program
Makecode Complete program link:https://makecode.microbit.org/_KYbTcpeawXAb
The Makecode complete program is as follows:
4. Running the Program
Click 'Download'. After the program has successfully downloaded, plug the micro:bit into the main control expansion board of the Maqueen Plus, and turn on the power switch of the car. Next, you can wake up the voice module by saying the wake word 'Hello Robot', and then control the car lights and the opening and closing of the gripper through the fixed voice command words.
Challenge Yourself
Are you looking to use other wake words to activate the voice recognition module? You can try learning a new wake word 'Hi Maqueen' to activate the voice recognition module, and then control the Maqueen Plus car to perform corresponding operations through fixed command words.
For methods on learning new wake words, you can click the link to view Learning wake-up word.
What other voice control features would you like to add to this car? You can leave a message, and we can work together to transform the voice-controlled vehicle!
Click Buy BBC micro:bit V2
Click Buy Offline Language Learning Voice Recognition Sensor
Click Buy micro:Maqueen Plus V2 (18650 Battery)
Click Buy micro:gripper
Click Buy micro:Maqueen Plus V2 (18650 Battery) with micro:Maqueen Mechanic
If you are interested in other micro:bit voice control projects, you can click to view:Smart Home Voice Recognition Control System You Must Try with micro:bit