• sales

    +86-0755-88291180

Chapter 11 of KitiBot-Microbit User Guide

Chapter 11 of KitiBot-Microbit

KitiBot, after seen a high-speed rail moving fast along the track, he hopes to have same track to move along, like a high-speed train. In this chapter we will learn about the “tracing function” of kitiBot. The aim of this chapter is to learn about the tracking sensor, and how to use it to implement the robot patrolling function.

Tracking sensor: the tracking sensor helps the robot move along the black line on the ground. There are five detectors at the bottom of the sensor, and the infrared LED light is used to project infrared light to the ground to detect the deviation of the module relative to the black line.


Blocks

 The detection range of different sensors are different, so we need to calibrate sensors to get their min and max values, then calibrate original data. To use this block, you need to put the robot on center of black line, move left and right to get dozens of data for calibrating.

  Get original data (five data) from infrared tracking sensor

  Get the maximum value which every sensor able to detect after calibrating

  Get the minimum value which every sensor able to detect after calibrating

  Read the position of black line, range of data is 0~4000, 0 stands for left side, 4000 stand for right side, 2000 means center.

Section 1

This section, we read original data of tracking sensor from serial port. Let's see how will these data change.

We read the data and save it to various item, then send the data to serial port.

https://cdn.static.spotpear.com/uploads/picture/learn/micro-bit/micro-bit-kit/chapter-11-of-kitibot-microbit/chapter-11-of-kitibot-microbit-07.gif

Connect the micro:bit to PC, and search the COM port on Device Mangaer. Download the code to micro:bit. Open serial assistant software, set baudrate to 115200. Five data will be printed to software. If you higher the robot, the data will turn small to about 0~10. If you put the robot to white ground, the data will rise to 500~700, on black line, the output are about 100.


Section 2

We let the script to output the position of black line base on previous section



Download the code to micr:bit, you can see that data are output as below. When black line is under tracking sensor, the data are smaller, about 80~10. The right data is the position of black line. Note that these data are not be calibrated.


Section 3

We calibrate the output data in this section

https://cdn.static.spotpear.com/uploads/picture/learn/micro-bit/micro-bit-kit/chapter-11-of-kitibot-microbit/chapter-11-of-kitibot-microbit-13.gif

Put the robot on ground, and make sure the black lines is on the center. After 3s (run the code), robot begin to calibrate, turn left first, then turn right, finally turn back to original place. During calibrating, the min and max values of every sensor will be printed, and data calibrated.


Section 4

In previous sections we learned about how to read the data of tracking sensor, here let's make robot to move along the black line. That is make robot turn right to back to black line when the data show that black line is on the right by slowing down the right motor, and turn left if the black line is on the left by slowing down the left motor.

https://cdn.static.spotpear.com/uploads/picture/learn/micro-bit/micro-bit-kit/chapter-11-of-kitibot-microbit/chapter-11-of-kitibot-microbit-16.gif


The P on the code is position tolerance, if it is positive, means robot deviation to right, and robot deviation to left if it is negative.

D is the difference between current P and last P, bigger the D, faster the robot response.

dif is the value which motor need to change, this value is based on P and D

TAG: DeepSeek XiaoZhi AI Voice Chat ESP32-S3 All-in-One-PCB-Kit N16R8 WROOM-1-N16R8 DevKitC-1 Development Board Raspberry Pi 5 Pure-Copper Cooler RP2040 Jetson Nano IO Board Raspberry Pi AI HAT+ Official Original Hailo-8/8L 13/26Tops For Pi5 PCIe M.2 Gen3 Raspberry Pi Prism Raspberry Pi RP2040 Keyboard EchoEar ESP32 S3 AI Development Board with 1.85-inch LCD Display Cute Cat Pet Chatting Robot N32R16 Luckfox Pico Camera User Guide Core3566102032 Bevelopment Board E-Paper Raspberry Pi screen Raspberry Pi 5 Active Cooler Raspberry Pi 3.5 inch LCD G Display Resistive TouchScreen 60fps ST7796 320x480 Also For Arduino/Pico2/ESP32/RP2040/RP2350 Raspberry Pi 5 PCIe to 4-CH M.2 NVMe 4-Ports SSD Board HAT Pi5 Four-Times ESP32-S3 Industrial 8-CH Relay IOT LAN WiFi /Bluetooth /CAN /RJ45 Ethernet /POE ESP32 Thermal imaging camera ESP32-P4 Pico WIFI6 Development Board C6 MIPI DSI 10.1-inch Display /CSI Camera /Audio Speaker Mic AI Deepseek Jetson-nano-to-boot-the-system User Guide