Micor:bit AI Lens Line-tracking Car

Introduction: Micor:bit AI Lens Line-tracking Car

About: ElecFreaks is an open design house founded in March 2011. Our goal is to create rapid prototypes and give small-batch manufacture solution for makers and startups. With over 50% staff as engineers and expanded…

Result
The car drives along with the black line. (Note: the background color must be pure white for this function)

Supplies

  • micro:bit * 1
  • Nezha Expansion Board * 1
  • Planet X series-AI Lens * 1
  • Planet X series- Motor Brick * 2
  • RJ11 wire * 1
  • n * Bricks

Step 1: ​Hardware Connection

Connect the micro:bit to Nezha expansion board, and connect the AI Lens to the IIC port on the Nezha expansion board with RJ11 wires, then connect the two motors to M1&M2 accordingly as the picture shows.

Step 2: Bricks Build-up

Step 3: Programming

Go to the MakeCode programmming page https://makecode.microbit.org/#editor

Step 4:

Add planet X package and click extensions on the menu of the settings on the right upper side.

Search with PlanetX in the dialogue box to add the package.

Add Nezha package in the same way.

After finishing the above steps, now we need to programme:
Initialize the AI lens via IIC port in the On start brick. Set the AI Lens in the line-tracking mode. Get one image from the AI Lens in the forever brick and set the motor M1 at speed 10% if the black line in the image being detected deviating to the left; and set the motor M1 at speed 60% if the black line in the image being detected deviating to the right side. Or set both the speed of M1 and M2 at 60%.

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

Be the First to Share

    Recommendations

    • Arduino Contest

      Arduino Contest
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Barbecue Speed Challenge

      Barbecue Speed Challenge

    Comments