Universal Robot Extension

Universal Robot Extension

Ever noticed how most beginner robots have the same purpose? Why not make a standard for blocks.

It is amazing to have so many robot options to choose from. More choices mean you can find what best suits your needs. Most beginner smart robot cars have 2 motors, same HC_SR04 distance sensor, 2 line sensors on the sides of the front wheel and some type of RGB lighting.

We decided that it would be nice to have a general code block set for these objects. So we went ahead and made it. Any robot we make in the future will follow this format, so let’s break it down.

Motors

The motors group consists of two basic functions. Driving the specified motor, going forward or backward and from 0% to 100% speed. 100 is the fastest you can go. Then there is the stop function which stops either left or right motors or both.

Distance Sensor

The distance sensor is usually located at the front of the car. It has two functions, it sends out a pulse and then takes in that pulse and thanks to some handy math functions, calculates the time it takes to get back to the senor to get the distance. One of the silver “eyes” sends the pulse and the other receives. Keep note of this when you think your robot is acting up but one of the sensors is covered up!

In the extension, the block returns a number. So if we wanted the Micro:bit to display the distance, we would use the Basic “show number” function like in the picture below.

Line Reader

The way the line readers work is that they are constantly reading the pin it is set to and returning either “True” (That it detects a line) or “False” (If no line is detected). This is called a boolean statement. When I went about making the block, I decided it would best be read as a sentence. So we will use an “If statement” block when we use the line reader block like the example below.

Lights and Other

Sometimes, there is no function to control the lights. This is because there is already a handy Neopixel extension. This extension is a requirement in most of the robots but it is still easy to use. Depending on the robot, the blocks look like this…

In this case, I named my variable for the lights “MaqueenLights”. By default, it will say “Strip”. The other two factors are the pin being used and how many LEDs. We can figure out how many LEDs by just counting the LEDs on the car but for what pin is being used, in this case, pin P15, is a little different each time so make sure you read the post about it.

Sometimes, certain cars will have more features than others. In this case, they will be covered in their post while this one is meant to convey the basic, universal ones

2 Likes

Well, I 've used your extension on the Maqueen Microbot and it works well. I don’t see IR control extension for any radio or tv remote such as in the DFRobot extension…maybe I;m not looking in the right place? I do see that you are not using the “patrol” extension which DFR uses for their line follower program , you’re using line reader detects and seems to work well too. Now, here’s my question. You don’t specify in this post if the extension is for Micro:bit in general or DF Robot MicroBot Maqueen ? if for Micro:bit , then does that imply that it will work with Yahboom bot which is much the same kind of two wheeled “robot” which also uses Microbit but a different set of extensions for their bot? Reason I ask is because the Yahboom has a .hex file which is most useful for bluetooth control of their bot but cannot be altered (increase wheel speed for slow line follower or the like) as it will not compile if opened in MakeCode app. You think your extension will work? Also, Yahboom makes a number of other robotic arms and such using Microbit and MakeCode, will your universal extension work with them too?

1 Like

There will be multiple extensions for each robot but they all share the same interface. The idea is that you do not need to learn anything new going from one robot to another.

As for IR, the code is messy and non portable. We are still studying different options to see what would be the right way to add it.

Thanks, Gus.

1 Like

Hi Frank, as Gus said, the universal extensions are for the blocks to act, and look the same for all the robots so you don’t have to learn any new blocks going from one robot to the other. As for missing blocks like the “patrol” one, we decided to strip out any functions that do the task for you. We believe it is better for teachers and students to learn how the logic in follow a line works and we are here to teach you. We rather not have functions like “follow black line” that does all the work for you. As for the IR code, it is pretty messy and haven’t gotten the chance to work on that part yet but i am sure I can find a fix for you soon.

As for your error, “020” it simply means the Micro:bit ran out of space since the file was too large. Which relates back to the IR code being messy and non portable.

Thank you

Time to upgrade to a BrainPad?