Cutebot Pro is an easy-to-use programmable robot for STEAM education, which inherits the playability and simple operation of micro:bit. With a compact body, encoder motors, and many standard features, it allows students to quickly learn how to control a programmable robotic car in an entertaining way, while nurturing their interests in science and logical thinking.
Picture below shows all the components and functionality provided by the kit. For a detailed description of the kit features, please refer to the product WIKI.
MicroBlocks fully supports the Cutebot Pro.
For each block, there is a short description entry and a detailed block and component description. You can click on block pictures in the short description table to access the details and sample codes.
Sample codes on how to use the blocks have been provided. To try them out, all you have to do is open a browser session of the MicroBlocks IDE and drag and drop them onto the editor programming area. Then you can just click on them and see the results.
The NeoPixels located at the bottom of the kit are not directly controlled by this library. The MicroBlocks Neopixel library should be used for that. Pin number for the NeoPixels is 15. and the LED count is 2. CBPro_enableNeoPixels block will setup the pin and led counts, so you can start using the NeoPixel library immediately.
To test any of the sample codes below, just drag and drop them onto the MicroBlocks IDE.
The library consists of a set of simple services, that together allow the user to have complete control of the Cutebot Pro Car Kit.
Since some of the components are located on and powered by the main board, it is necessary to have a battery connected and main board power switch set to ON position in order for these components to function properly.
For the MOTORS: The RIGHT and LEFT designations are based on the view from the top and back of the car towards the front.
For the LIGHTS: The RIGHT and LEFT designations are based on the view from the top and front of the car towards the back.
Cutebot Pro Library has two distinct types of block shapes:
oval: these are reporter blocks that return some kind of information back. The user would normally either assign these to a project variable or use it in a suitable input slot of other blocks. The return information type is a Number.
rectangular: these are command blocks that perform a programmed function and do not return any information.
Moves car at selected speeds (cm/s) for each wheel. Setting of ZERO (0) will stop the car.
Returns the speed of the selected wheel in cm/s. The speed is calculated by the encoder values produced by each wheel.
Stops the selected wheel.
This block stops the car movement, stops the external motor, turns off the NeoPixel and Headlights. It is quick way to reset the car status.
Drives the car for a specified distance (in cm) in the direction selected.
Be careful with using this block, as it may cause your vehicle to execute a speedy movement.
This block turns the car clock-wise / counter-clockwise 0-360 degrees. Selecting negative values will reverse the turns (counter-clockwise). The turn is in place, meaning both wheels will be used to achieve the turn, pivoting the car around its center point.
This block also updates the orientation value for the car, enabling one to determine the orientation of the car after a specific number of turns. The _cbpro_clearEncodersAndOrientation block has to be used before the turns, to establish a starting point for the Orientation calculations.
Due to calculation inaccuracies, very small angles ( <= 15 degrees) will not be very precise.
This example makes the car execute a LEFT turn of 90 degrees.
Positive angle values turn the car clockwise, and negative values counter-clockwise.
Used to turn on/off and set colors of the two RGB LEDs on top of the car.
The light is turned off by setting its color value to black or 0.
Example code makes the headlights flash RED and GREEN three times.
There are two NeoPixels on the bottom of the Cutebot Pro. You can set the colors on these with this block.
For a more detailed ability to control the NeoPixel functionality, please refer to the NeoPixel Library details.
Two NeoPixel LEDs located at the bottom of the car are made to display 10 rounds of random colors.
The HC-SR04 sonar distance sensor will measure the distance to any objects placed in front of it. The result returned will range from a 2cm to 400cm.
This can be used to implement obstacle avoidance type applications, or as a measuring device. One needs to be aware of how various materials and objects reflect / absorb the transmitted ultrasound signal. It may result in erroneous readings.
This block returns the interpreted line sensor result such that it is easier to code the line tracking actions. There are a total of 16 conditions that the four Line sensors can be reporting. When the selected 4-sensor setting in the block matches what the actual sensors detect, TRUE will be reported.
Using these, it is very easy to use when condition blocks to steer the car.
Example code checks to see if the middle two tracking sensors are in the black line, and if TRUE, moves the car straight at 40cm/s speed.
Returns a value 0-15, representing the binary on-status of the four Line sensors, as viewed from behind of the car.
Returns a value between -3000 and 3000, representing the tracking state. The number is an expression of how far away from the center value the sensors are.
This is used in the PID formula to calculate the error rate and make corrections to the car path.
Example provided is a PID algorithm implementation, to drive the car around the elliptical track provided with the kit.
This block returns TRUE if any IR codes are detected by the IR sensor. It is normally used together with the next block (CBPro IR code) to program the IR Remote buttons to perform any desired actions.
You need to point the IR Remote towards the IR sensor, located at the mid-rear of the car kit, and press any buttons on it. The sensor works with keypads that produce NEC keycodes.
Please note that when this block is executed, it will wait until an IR key is pressed. Therefore, it may have a blocking effect on the code executing, if placed inappropriately.
The code shown implements a custom function to evaluate whether a specific button on the Arduino-style Remote control has been pressed. It returns TRUE if the selected button is pressed.
When you drag and drop the picture of the define block below onto the MicroBlocks IDE, a custom function will be created under the My Blocks category.
At that point, your My Blocks category will look like this:
To use the custom block, enter a button name shown in the IRbuttons list into the entry area of the block. Here is an example of checking for the UP button:
Ths code can be used to quickly evaluate button presses and direct the car accordingly.
Here is an example of making the car turn RIGHT, when the IR Remote RIGHT ARROW button is pressed:
NOTE: This example is very specific to the Arduino style Remote Control. There are many different types of Remote controls. Unless you happen to have the exact version shown, the code most likely will not work as it is. However, the code can be customized to the type of Remote control you may have. |
This block returns the numerical value of any IR codes are detected by the IR sensor. It is normally used together with the previous block (CBPro IR code received) to program the IR Remote buttons to perform any desired actions.
Refer to example above
It sets the degrees of turn for the angular movement servos.
There are four extension ports in the back of the car, used for attaching servos. See picture in Overview section above.
Example moves the servo#1 in a 180 degree sweep 3 times.
It sets the rotation speed and direction for continuous motion servos.
There are four extension ports in the back of the car, used for attaching servos. See picture in Overview section above.
Example runs the continuous servo attached to S2 port for 2 seconds at speed 50, and then stops it.
This block controls a DC motor attached to the external motor connector. It is located right behind the right side of the micro:bit edge connector. See picture in Overview section above.
Example code ramps up and down a DC motor attached to the external motor port, and then stops it.
Stops the DC motor connected to the external motor connector.
Refer to example above.
Returns the firmware version fo the Cutebot Pro main controller board.
Enables control of the wheels by setting a power percentage for each motor.
Negative values are used for movement in reverse direction.
Example puts the car in a 75% power left turn for 2 seconds, and then stops it.
Clears encoder values of both wheels and the calculated orientation of the car.
These are stored in variables:
Refer to example below.
This block returns the Orientation value for the car after any turn executions.
The _cbpro_clearEncodersAndOrientation block has to be used before the turns, to establish a starting point for the Orientation calculations.
Example clears the Encoder and Orientation data for the car. Then it puts the car into three separate turns maneuvers. At the end it displays the orientation of the car. Positive turns are added and negative turns are subtracted from the final orientation calculations.
The Encoders on the Cutebot Pro motors keep track of the revolutions the wheels make. This block sets the two variables _cbpro_leftCount and _cbpro_rightCount to the corresponding values.
These values, as well as the Orientation value can be cleared with the _cbpro_clearEncodersAndOrientation block.