21.2. Control the Cutebot with the Cards in Different Colors#

Purpose#

Working with the AI lens, the Cutebot car is able to be controlled by starting moving or stopping by the cards in different colors.

Materials#

1 × Cutebot car

1 × Cutebot lithium battery pack

1 × AI Lens

Note: AI lens is for Cutebot V 3.0 and above (you can see the version number printed on the base plate).

Assembly#

The installation steps of lithium battery pack:#

../../../_images/cutebot-step-01.png

Construction steps of the building blocks:#

Parts List:

../../../_images/cutebot-step-02.png

Build steps;

../../../_images/cutebot-step-03.png

../../../_images/cutebot-step-04.png

../../../_images/cutebot-step-05.png

../../../_images/cutebot-step-06.png

../../../_images/cutebot-step-07.png

../../../_images/cutebot-step-08.png

../../../_images/cutebot-step-09.png

AI Lens connection:#

Connect the RJ11 connector to the AI lens, and the other end of the Dupont cable connector to the location shown in the figure below, you need to pay attention to the correct interface of the connection cable.

../../../_images/cutebot-step-10.png

Note: This block stand structure is movable and we can manually adjust the viewing angle of the AI lens. When using the AI camera, the angle should be adjusted according to the functional requirements.

Software#

MicroSoft Makecode

Program#

Step 1:#

Click “Advanced” in the drawer of MakeCode to see more choices.

../../../_images/cutebot-case-24-01.png

For programming, we need to add a package. Click “Extensions” at the bottom of the drawer and then search Cutebot in the dialogue box to download it.

../../../_images/cutebot-case-24-02.png

For programming, we need to add a package. Click “Extensions” at the bottom of the drawer and then search PlanetX-AIin the dialogue box to download it.

../../../_images/cutebot-case-24-03.png

Note: If you get a warning indicating some packages will be removed because of incompatibility issues, you can follow the prompts or create a new project in the menu.

Step 2:#

In on start, initialize the AI lens, switch the lens function to color recognition mode, and initialize the rainbow light.

../../../_images/cutebot-case-24-04.png

In Forever,get the information of a frame from the lens, if the image contains red card, the cart stops and shows red light, if the image contains green card, the cart moves forward and shows green light.

../../../_images/cutebot-case-24-05.png

Program#

../../../_images/cutebot-case-24-06.png

Link: https://makecode.microbit.org/_2781gFCseJMs

You can also download the program directly from the following webpage.

Result#

When the AI lens detects a red card, the cart stops and shows a red light, and when the AI lens detects a green card, the cart continues moving forward and shows a green light.

Exploration#

Is it possible to set more functions for Cutebot smart car and switch functions by recognizing color cards?

FAQ#


Relevant reading#