20.3. Cutebot & AI Lens Discoloring Lights#

Purpose#


  • Change the color of the lights via the color of the cards with the Smart AI Lens.

Materials required#


Note: The AI Lens kit works with Cutebot V3.0 only(You can see the version number printed on the baseboard).

../../../_images/cutebot-16-04.png

Connections:#


Steps to install the lithium battery pack:#

../../../_images/cutebot-step-011.png

Assembly steps for bricks:

Parts list:

../../../_images/cutebot-step-021.png

Steps of build-up:

../../../_images/cutebot-step-031.png

../../../_images/cutebot-step-041.png

../../../_images/cutebot-step-051.png

../../../_images/cutebot-step-061.png

../../../_images/cutebot-step-071.png

../../../_images/cutebot-step-081.png

../../../_images/cutebot-step-091.png

Connections of the AI Lens:#

Connect the RJ11 cable with the AI Lens and the other end in Dupont connection to the circled place in the below picture (make sure you connect to the right connections).

../../../_images/cutebot-step-101.png

Tips: the bricks holder here is flexible to be adjusted, we may manually adjust the angles of the AI Lens to meet the requirements of the functions that you want to achieve.

Software Platform:#


MicroSoft MakeCode

Programming#


Step 1#

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

../../../_images/cutebot-pk-1.png

  • We need to add a package for programming. Click “Extensions” in the bottom of the drawer and search with “cutebot” in the dialogue box to download it.

../../../_images/cutebot-pk-11.png

We need to add a package for programming the AI Lens kit. Click “Extensions” in the bottom of the drawer and search with “https://github.com/elecfreaks/pxt-PlanetX-AI” in the dialogue box to download it.

../../../_images/cutebot-pk-12.png

Note: If you met a tip indicating that the codebase will be deleted due to incompatibility, you may continue as the tips say or build a new project in the menu.

Step 2#

  • In the “on start” brick, initialize the AI Lens and switch the function to the color recognition mode, set the RainbowLED lights connect to P15 port.

../../../_images/case-18-011.png

  • In the “forever” brick, set to get one image form the AI Lens and judge the cards color on the image. If it reconizes the white color, we set the LED headlights and signal lights in white; if we recognizes the blue color, we set the LED headlights and signal lights in blue, by analogy, we programme with green, red, yellow and black card in the same way.

../../../_images/case-18-021.png

Code#

../../../_images/case-18-03.png

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

You may also download it directly below:

Result#


  • The lights change the color in accordance with the color of the cards.

Exploration#


FAQ#


Relevant Files#