Moth Robot | Maqueen Plus V2 Getting started Tutorial 06

0 1227 Easy

You must have seen that at summer night, plenty of moths fly around the streetlight, flame, and any places with bright light. Why are moths attracted to flame? One idea is that moths are able to find their way partly by using light as a compass. You know what, Maqueen Plus V2 can turn into a moth robot because it has a pair of light-sensitive eyes.

Goal

1. Learn condition block

2. Design a flowchart to help program

Command Learning

Hand-on Practice

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. When the light level is more than the given value (100 in the example), the moth robot moves towards the light source; when less than that value, the robot revolves around its center. Drawing a corresponding flowchart according to the above functions is gonna help us a lot with programming!

2. Put the “if...then...else” block inside the “forever”block, and embed the comparison operator block into it.

3. The key point of the whole program is the condition statement “light level >100”. Different operations will be executed according to the result of the condition block.

4. When the condition“Light level>100”is true, the robot car moves forward at the speed of the current light level.

5. When the condition“Light level>100” is false, the Maqueen Plus V2 rotates around its center.

6. The complete program is shown below.

7. Name your project as “Moth robot” and save it.

STEP 3 Download Program

1.Connect to PC: connect the micro:bit to your computer with a USB cable before downloading.      There will be a hard disk named micro:bit appearing in the computer when the connection is successful.

2.Download the program: download your project into the micro:bit hard disk.

3.Plug in the micro:bit board: after downloading the program, plug the micro:bit board into Maqueen Plus V2.

STEP 4 Effect Display

Turn on the power switch, then Maqueen Plus V2 will turn into a moth robot. When the light level is over 100, our moth robot moves towards the light, the brighter the light is, the faster Maqueen Plus V2 runs. When the light is less than 100, the robot will lose its way and rotate around. So funny, right? Come to play with this moth robot!

Think & Explore

Let’s do a robot running competition! Use a flashlight to lead Maqueen Plus V2 to run forward, the one who uses the least time to finish the game will be the winner. Remember, do not cross the line. Invite your friends to join the game!

Tips: maintaining speed within a reasonable range holds the key to success.

 

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:Little Ranging Expert

Engage in learning the previous Robot project :  Light Sensing Robot

 

 

 

License
All Rights
Reserved
licensBg
0