Max:Bot Run

0 4552 Easy

Hi there, he is Max:Bot, your personal robot companion. I believe you have already been obsessed with his shiny skin. You must want to play with him now. The first thing we want to do is to set it on moving and let’s get it started.

projectImage

🔸 Goals:


1. Set the wheels running.

2. Learn how to steer the Max:Bot.

3. Run in a pattern.


🔸 Component

projectImage

💜 1.1 Go forward


🔸 Key information

projectImage

🔸 Program


(1) Open makecode: http://microbit.dfrobot.com.cn/index.html

(2) The “on start” module will not be used in this part. So we have to delete it. We just need to drag and drop it to the function area. It will then be deleted automatically. This method is also available for all other functions.


projectImage

(3) Find the “servo write” function from “Pins” in the function area. This function controls the speed of motors.

projectImage

(4) Put the “servo write” function into the “forever” loop. Please note: the left wheel should be connected to P12, and the right to P8.

projectImage

(5) Now please upload it to Max:Bot . Wow! Can you see that? Max:Bot is going forward!

projectImage

After downloading, you have to remove the USB cable from the computer.

And the battery module should be connected to Max:Bot.


🌟 If Max:Bot still not move, please check if you have switched it on.

projectImage

🔸 Exercises


It is you that allow Max:Bot to move forward. He really appreciates it. But he also wants to know how to go backward. Will you help him with this? Tips: the number in the “servo write” function controls the speed, try to set different values.

projectImage

💜 1.2 Go in circles


🔸 Key information:

projectImage

Please note: the “function” and “call function” are all lie in

“Advanced” => “Functions”. But both of them are not listed in it directly.


🔹 The way to find them goes like:

1. Way to find “function”: “Advanced” => “Functions” => “Make a Function”. Click “Make a Function”, name it and click “OK”. Then you will find this “function” block appears in the programming area automatically.

2. Way to find “call function”: at the same time the “function” block appears in the programming area, the “call function” block appears in the “Functions” of function area. Please remember that the “call function” appears only when the “function” is created.


🔸 Program

(1) Start a new project and name it as “ Round in circles”

Click “Projects”.

projectImage

Please note: To avoid any confusion, we have to start a new project, otherwise makecode would save it directly into the last project file.

projectImage

Name it: Round in circles

projectImage

(2) Here we need to create a sub-loop. It goes as: “Advanced” => ”Functions” => ”Make a Function”.

projectImage

Click “Make a Function” and name it as: Rotate. Then you will find the “function” block appears in the programming area automatically. And at the same time it is created, the “call function” appears in the “Functions” of the function area.

projectImage

(3) How to make Maxbot turn?

Before programming, we will need to first get familiar with the “differential steering” principle.

projectImage

Therefore, the key to success is to rotate the two wheels in different speed. Place the “servo write” functions into the “function” sub-loop.

projectImage

The “180” is the top clockwise rotation speed, whereas the “0” is the top anticlockwise rotation speed.


Above we have created the sub-loop named “Rotate”. We need now to place the “call function” from “Functions” into the “forever” loop. Thus the actions in the “function” will be executed by the “forever” loop.

projectImage

(4) Combine all function blocks listed above together, we will have the final program as below:

projectImage

Download the program to Max:Bot , it will then rotate in circles clockwise.


💡 Do not forget to remove the USB cable and switch Max:Bot on.


🔸 Exercise

Tip: It is the value of “servo write” also controls the speed of the robot, set this try to use a different value.

projectImage

💜 1.3 Round in squares


🔸 Key information

projectImage

🔸 Program


(1) Start a new project and name it “Round in squares”


(2) Create another two sub-loops and name them as “Go” and “Turn Left”. Have you remembered how to create them? We will review it together: “Advanced”=>”Functions”=>”Make a Function”.

projectImage

As we all know that if one would like to round in squares, he/she must be firstly walk straight for a while (like 1 minuet), then turn 90 degrees and keep walking forward for another minuet... These moves will be repeated until he/she finished a square.


(3) Therefore, we will need first to make it go straight. As have mentioned in previous parts that the “servo write” function can be used to control the speed of wheels and make Max:Bot go forward. So we will use it in this part. Set both the values as “0” to keep the two wheels rotate in the same speed. And then put the “servo write” into “function(Go)”.

projectImage

(4) We have also learnt the “differential steering” principle to make Max:Bot rotate. But here, we have to adjust the values to make it turn 90 degrees only. Set P8(the left wheel) as “0”, and P12(the right wheel) as “90”. The value ”90” means the wheel is to be kept still.

projectImage

Compared with the “function(Rotate)”, the values “0” and “90” set in the “function(Turn around)” means:

The “90” in P12 means the right wheel rotates 0 degree. The “0” in P8 means the left wheel rotates at the top anticlockwise speed. Thus, Max:Bot turns right.


(5) Place both the “call function(Go)” and the “call function (Turn around)” into the “forever” loop. The final program goes as:

projectImage

💡 Does the Max:Bot go in square now? I suppose no. We have to be more patient about it. No pain no gain.


To ensure Max:Bot round in squares, we have to give him enough time to move forward and turn. We need the “pause” function here to set the time. You can find it in “Basic” of the function area. Place it into the “forever” loop.

projectImage

The program goes as below:

projectImage

Please note:

a. The “2000” determines the side length of the square.

projectImage

b. The “1000” determines the rotation angle.

projectImage

Different batteries output different voltages. So, the “2000” and “1000” here are just used for a reference. You have to try and adjust them based on the actual situation. Remember what we have just said: No pain no gain. Just try it!


(6) Combine all the functions listed above together, the final program is as following. Make sure you have made every step correctly and then download it to Max:bit.

projectImage

You did it! It now rounds in squares!


🔸 Exercise


Once you have made it round in squares, it is a piece of cake to round it in triangle. Try it!

projectImage
License
All Rights
Reserved
licensBg
0