AI Lens Line-tracking Kit

Purpose


  • Use the Cutebot and the AI lens to achieve the line tracking function.

Materials required


../../_images/cutebot-16-041.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-13.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-111.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-121.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 line tracking mode, set the micro:bit to display the appointed icon.

../../_images/case-16-011.png

  • In the “forever” brick, set to get one image form the AI lens and judge the deviation direction of the line on the image. If it deviates to the left side, it means the car deviates to the right, we should set the speed of the left wheel at the speed of 10% and the right at 40% to make the car turn left and go to the right way; if the line deviates to the right side, it means the car deviates to the left side, now we should set the speed of the right wheel at the speed of 10% and the left at 40% to make the car turn right and go to the right way; or we may set the speed of both wheels at 20% and the car moves forward with the line.

../../_images/case-16-021.png

Code

../../_images/case-16-031.png

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

You may also download it directly below:

---

Result


  • The Cutebot car moves along with the black line.

../../_images/case-16-041.gif

Exploration


FAQ


Relevant Files