Motion Sensing Robot | Maqueen Plus V2 Getting started Tutorial 12

0 1044 Easy

Have you ever tried motion-sensing games, like racing cars? This kind of game requires us to control the movement of the car on the screen by changing the direction of the remote controller. It is extremely exciting! Our Maqueen Plus V2 can also realize motion-sensing since the accelerometer on the micro:bit can detect the orientation of the board. With accelerometer and radio communication functions, we can make a similar motion-sensing game using Maqueen Plus V2.

Goal

1. The basics of radio communication

2. Learn how to use the accelerometer sensor

Electronic Component

Command Learning

What is an accelerometer sensor?

An accelerometer is a device that can detect the change in an object's acceleration. The onboard accelerometer of micro:bit can sense the motion of the micro:bit, including its movement, angle, gesture, and so on.

Hands-on Practice

Motion Sensing Robot - Transmitting End

Before we start programming, let's analyze how to use the accelerometer sensor in this project.

The movement of the robot car is controlled by the gesture of micro:bit. When micro:bit logo faces up, an "Up arrow" shows on the LED screen, and then the car moves forward; When logo down, show "Down arrow" and the car moves backward; tilt left, show "left arrow" and the car turns left; tilt right, show "right arrow" and the car turns right.

Tip: to realize radio communication, we need two micro:bits here. One for transmitting signal (Transmitting end), one for receiving signals (Receiving end).

Step 1 Create a New Project

1. Input https://makecode.microbit.org/ into your browser to enter the MakeCode editor.

2. Click "new project" to enter the MakeCode programming interface.

3. Add the Maqueen Plus V2 library: https://github.com/DFRobot/pxt-DFRobot_MaqueenPlus_v20

Step 2 Programming

1. Enable the radio communication, and set the radio group to 1.

2. When the micro:bit logo is up, show an "Up arrow" on its LED screen, and send data 1 via radio to the Maqueen Plus V2.

The programs for the rest actions of micro:bit works in the same way. (Note: The numbers in the "radio send number" block can't be the same.)

3. The whole program for the transmitting end is shown below:

4. Name your project "Motion sensing robot-Transmitting end" and download it into the micro:bit of the transmitting end.

Motion Sensing- Receiving End:

Step 1 Create a new project

Step 2 Programming

1. Enable radio communication function, and set the radio group to 1. (The radio group of the transmitting end should be the same as that of the receiving end.)

2. Program Maqueen Plus V2 to react according to the received signal.

3. Create four functions "move forward", "move backward", "Turn left", and "Turn right".

4. We have to use radio receive block to control the Maqueen Plus V2 to do different reactions according to the received data.

5. Take the function "move forward" as an example. When the Maqueen Plus V2 car moves forward, we let its LED screen display an "Up arrow".

Please complete the rest functions by yourself.

6.  The program of the receiving end is shown below:

7. Name your project "Motion sensing robot-Receiving end" and then download the program to the micro:bit in Maqueen Plus V2.

Effect Display

When completed all the above steps, turn Maqueen Plus V2's power switch on, then we can use the micro:bit of the transmitting end to control our car. Give it a go!

Think & Explore

When playing a motion-sensing game, the larger angle we turn, the larger angle the object moves on the screen. How do we achieve this on our Maqueen Plus V2?

 

Click Buy micro:Maqueen Plus V2 (Ni MH Rechargeable Battery) - an Advanced STEM Education Robot for micro:bit - DFRobot

Click Buy micro:Maqueen Plus V2 (18650 Battery) - an Advanced STEM Education Robot for micro:bit - DFRobot

Engage in learning the next Robot project:Firefighting Robot

Engage in learning the previous Robot project :  IR-controlled Robot

License
All Rights
Reserved
licensBg
0