Difference between revisions of "Getting Started with BPI-QCar"

From Banana Pi Wiki
Jump to: navigation, search
(Q-Car 配合BPI:Bit 使用Arduino环境编程)
(Line patrol)
(38 intermediate revisions by 2 users not shown)
Line 23: Line 23:
 
=BPI-QCar with BPI:Bit for Arduino IDE =
 
=BPI-QCar with BPI:Bit for Arduino IDE =
  
Arduino是一款便捷灵活、方便上手的开源电子原型平台。在社区的努力下,BPI:Bit可以通过Arduino环境编程,具体环境搭建教程可以参考[[BPI:bit_for_Arduino]]
+
Arduino is an open source electronic prototyping platform that is flexible and easy to use.With the help of the community, BPI: BIT can be programmed with the Arduino environment, which you can refer to in the tutorial
 +
[[BPI:bit_for_Arduino]]
  
==电机控制==
+
==Motor control==
学习目标:掌握Q-Car的电机控制基本方法
+
Learning Objectives: Master the basic motor control method of Q-CAR
  
程序效果展示:小车前进1秒,停100ms,后退1秒,停100ms,左转1秒,停100ms,右转1秒,停100ms。
+
Program effect display: car forward 1 second, stop 100ms, back 1 second, stop 100ms, left 1 second, stop 100ms, right turn 1 second, stop 100ms.
  
 
[[Image:Q-Car_Motor_Test.gif]]
 
[[Image:Q-Car_Motor_Test.gif]]
  
Arduino程序链接:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Motor_Demo
+
Arduino code link:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Motor_Demo
  
==氛围灯控制==
+
==Ambient light control==
学习目标:了解Q-Car的RGB氛围灯的基本使用方法
+
Learning Objectives: To understand the basic usage of Q-CAR RGB atmosphere light
  
程序效果展示:底部RGB氛围灯红、绿、蓝三色混合渐变显示出多种颜色,呈现出彩色呼吸效果。
+
Program effect display: bottom RGB atmosphere light red, green, blue three color mixing gradient display a variety of colors, showing a color breathing effect.
  
 
[[Image:Q-Car_Pixel_Test.gif]]
 
[[Image:Q-Car_Pixel_Test.gif]]
  
Arduino程序链接:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Pixel_Demo
+
Arduino code link:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Pixel_Demo
  
==超声波传感器控制==
+
==Ultrasonic sensor control==
  
学习目标:掌握Q-Car的超声波传感器的使用方法
+
Learning objective: master the use of Q-CAR ultrasonic sensor
  
程序效果展示:串口显示超声波测得的距离数据。
+
Program effect display: serial port display ultrasonic measured distance data.
  
 
[[Image:Q-Car_Ultrasonic_Test_1.gif]]
 
[[Image:Q-Car_Ultrasonic_Test_1.gif]]
Line 53: Line 54:
 
[[Image:Q-Car_Ultrasonic_Test_2.png]]
 
[[Image:Q-Car_Ultrasonic_Test_2.png]]
  
Arduino程序链接:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Ultrasonic_Demo
+
Arduino code link:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Ultrasonic_Demo
  
==蜂鸣器的使用==
+
==How to use buzzer==
  
学习目标:掌握Q-Car的蜂鸣器的使用方法
+
Learning objective: master the use of BPI-QCAR buzzer
  
程序效果展示:蜂鸣器播放“小星星音乐”
+
Program effect display: the buzzer play "little star music"
  
Arduino程序链接:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Buzzer_Demo
+
Arduino code link:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Buzzer_Demo
  
==红外遥控==
+
==IR control==
  
学习目标:掌握Q-Car的红外遥控
+
Objective: To master the infrared remote control of Q-CAR
  
程序效果展示:红外遥控Q-Car前进后退以及转弯
+
Program effect display: infrared remote control Q-CAR forward and backward and turn
  
 
[[Image:Q-Car_IR_Control.gif]]
 
[[Image:Q-Car_IR_Control.gif]]
  
Arduino程序链接:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/IR_Control_Demo
+
Arduino code link:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/IR_Control_Demo
  
==超声波避障==
+
==Ultrasonic obstacle avoidance==
  
程序效果展示:开机小车前进,超声波检测前方距离,如果距离小于8cm,小车左右查看两边障碍物,选择距离更远的方向拐弯,避开障碍物。
+
Program effect display: boot the car forward, ultrasonic detection of the front distance, if the distance is less than 8cm, the car left and right to check the obstacles on both sides, choose the direction of the farther distance to turn, to avoid obstacles.
  
配件准备:M2铜柱×2,M2螺丝×2,SR04超声波模块×1,超声波支架×1,舵机支架×1([https://github.com/BPI-STEAM/Q-Car/tree/master/Hardware/Servo%26Ultrasonic 支架下载地址]),杜邦线若干,插入前方的SR04接口。
+
Parts preparation: M2 copper column ×2, M2 screw ×2, SR04 ultrasonic module ×1, ultrasonic bracket ×1, steering gear bracket ×1([https://github.com/BPI-STEAM/Q-Car/tree/master/Hardware/Servo%26Ultrasonic Download address of bracket]),DuPont line number, insert SR04 interface in front。
  
 
[[Image:Q-Car_Avoidance_Demo.gif]]
 
[[Image:Q-Car_Avoidance_Demo.gif]]
  
Arduino程序链接:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Avoidance_Demo
+
Arduino code link:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Avoidance_Demo
  
==巡线行驶==
+
==Line patrol==
  
=Q-Car 配合 BPI:Bit 使用MicroPython环境编程=
+
=BPI-QCar with BPI:Bit use MicroPython=
  
=Q-Car 配合 Micro:Bit 使用MakeCode环境编程=
+
=BPI-QCar with Micro:Bit use MakeCode =
==MakeCode编程点亮Micro:Bit==
+
==MakeCode programming to light up the LED on Micro:Bit==
学习目标:熟悉基础的MakeCode的应用并在Micro:Bit的5*5LED矩阵上显示一些图形或文字。
 
  
打开Micro:Bit的MakeCode编程环境网页端:https://makecode.microbit.org/
+
Learning Objectives: Familiarize yourself with basic Makecode applications and display some graphics or text on the Micro:Bit 5*5LED matrix.
  
新建一个项目,参照下图的例程连接MakeCode积木,例如其中第一个积木块“show leds”可以在“Basic”选项栏目中找到,此积木可以自行编辑想要输出的图形
+
Open the Makecode programming environment web side of Micro:Bit:https://makecode.microbit.org/
 +
 
 +
Create a new project and connect the Makecode blocks with the following routine. For example, the first block "Show Leds" can be found in the "Basic" options column. This block can edit the desired graphics
  
 
[[Image:Microbit-screenshot_(display_graphics).png]]
 
[[Image:Microbit-screenshot_(display_graphics).png]]
  
右键积木可对积木进行一些操作,如添加注释,删除复制积木,以及'''查阅积木对应的说明文档''',这个对于初次上手的人来说能提供很大的帮助。
+
Right-click building blocks to carry out some operations on the building blocks, such as add notes, delete copy building blocks, as well as access to the corresponding documentation of the building blocks, this for the first time people can provide great help.
  
MakeCode编程环境有'''自带模拟程序运行效果的仿真器'''可以实时查看效果,通常显示在左上方
+
The MakeCode programming environment has an emulator with its own simulation of the program to view the effect in real time, usually displayed at the top left
  
MakeCode编程环境也支持从外部导入项目文件,如经过MakeCode编译生成的.hex文件
+
The Makecode programming environment also supports importing project files from outside, such as.hex files that are compiled by Makecode
  
例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-display-graphics.hex
+
Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-display-graphics.hex
  
'''注意''':正确的.hex文件导入方式是将上文链接中的.hex文件下载到本地然后将其导入到MakeCode中,而不是直接将此链接导入,外部项目链接导入MakeCode的方式与此处不同
+
'''Note''':The correct way to import *.hex file is to download the.hex file from the link above and then import it into the MakeCode, rather than directly importing the link. External project links import the MakeCode differently
  
 
[[Image:Makecode(import_file).png]]
 
[[Image:Makecode(import_file).png]]
  
项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行
+
The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly
  
==按钮控制Micro:Bit-基础==
+
==Micro:bit's Button control - Base==
  
学习目标:使用Micro:Bit上的AB两个按钮控制LED矩阵所要输出的图形
+
Learning Objectives: Use the two buttons A/B on Micro:Bit to control the graphics to be output by the LED matrix
  
在章节“使用MakeCode编程点亮Micro:Bit”的基础上,在MakeCode中“input”选项栏目中找到应用按钮控制的积木“on button A pressed”来进行编程
+
On the basis of the section "Using Makecode Programming to Light Micro:Bit", find the building block "On Button A Pressed" in the "Input" option column of Makecode to program
  
例程如下图,实现按一下A按钮显示英文字符“A”,按一下B按钮显示英文字符“B”,同时按下AB按钮后显示一个形似香蕉的图案
+
The routine is shown in the figure below. Press the A button to display the English character "A", press the B button to display the English character "B", and press the AB button to display A pattern shaped like A banana
  
 
[[Image:Using_the_button.png]]
 
[[Image:Using_the_button.png]]
  
例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Using_the_button_1.hex
+
Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Using_the_button_1.hex
  
项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行
+
The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly
  
==按钮控制Micro:Bit-进阶==
+
==Micro:bit's Button control -advanced==
  
学习目标:用MakeCode编程实现一个计数并显示的按钮控制程序
+
Learning objectives: Makecode programming to achieve a count and display button control procedures
  
在前一章节的基础上,先在MakeCode中“Variables”选项栏目中新建一个变量名为“A_was_pressed_times”的变量,此时将在“Variables”选项栏目产生多个关于变量的积木
+
Building on the previous section, create a new variable called "A_was_pressed_times" in the "Variables" section of the Makecode. This will generate multiple building blocks for the variable in the "Variables" section
  
将“Math”选项栏目中的加法积木与“Variables”选项栏目中的积木镶嵌组合,参照下图例程
+
Combine the addition blocks in the "Math" TAB and the Mosaic blocks in the "Variables" TAB. Refer to the following legend
  
 
[[Image:Using_the_button_2.png]]
 
[[Image:Using_the_button_2.png]]
  
此时,我们就实现了在MakeCode编程并做出了一个利用加法计数的程序,按一次按钮A计数加1同时将计数值输出到LED矩阵中,按一次按钮B计数归0并清除LED矩阵的显示
+
At this point, we realized in the Makecode programming and made A use of the addition counting program, press A button A count to add 1 at the same time the counting value output to the LED matrix, press A button B count to return to 0 and clear the LED matrix display
  
例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Using_the_button_2.hex
+
Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Using_the_button_2.hex
  
项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行
+
The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly
  
==车轮测速==
+
==The wheel speed measurement==
  
学习目标:用MakeCode编程实现读取Q-Car上用于车轮测速的红外对管的高低电平信号并用计数法算出车轮转速
+
Learning Objectives: Using Makecode programming to read the high and low level signals of the infrared pair tube used for wheel speed measurement on BPI-QCAR and calculate the wheel speed with counting method
  
例程如下图,将程序烧录进Micro:Bit,将Micro:Bit与Q-Car连接,此时旋转Q-Car左右轮,可以从USB串口中读取到左右轮转速
+
The routine is as shown in the figure below. The program is burned into Micro:bit, and the Micro:bit is connected to BPI-QCar. At this time, the left and right wheels of Q-CAR can be read from the USB serial port to the left and right wheel speed
  
 
[[Image:Q-Car_velocity_measurement_module.png]]
 
[[Image:Q-Car_velocity_measurement_module.png]]
Line 151: Line 153:
 
[[Image:Q-Car_velocity_measurement_module_Serial_port.png]]
 
[[Image:Q-Car_velocity_measurement_module_Serial_port.png]]
  
例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-Car_velocity_measurement_module.hex
+
Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-Car_velocity_measurement_module.hex
  
项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行
+
The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly
  
==电机控制==
+
==Motor control==
  
学习目标:用MakeCode编程实现Q-Car左右电机正反转控制
+
Learning Objectives: Using Makecode programming to achieve QCar left and right motor forward and reverse control
  
例程如下图,将程序烧录进Micro:Bit,将Micro:Bit与Q-Car连接,左右电机将同时正转2s,同时反转2s,右电机单独正转2s,左电机单独正转2s
+
Routines as shown in the figure below, the program is burned into the Micro: BIT, the Micro: BIT and Q-CAR connection, left and right motor will be turned to 2s at the same time, reverse 2s at the same time, right motor is turned to 2s alone, left motor is turned to 2s alone
  
 
[[Image:Q-Car_Motor_control_module.png]]
 
[[Image:Q-Car_Motor_control_module.png]]
  
例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-Car_Motor_control_module.hex
+
Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-Car_Motor_control_module.hex
  
项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行
+
The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly
  
==氛围灯控制==
+
==Ambient light control==
  
学习目标:用MakeCode编程实现对Q-Car上10颗WS2812B彩色氛围灯的控制
+
Learning Objectives: Use Makecode programming to control 10 WS2812B color atmosphere lamps on BPI-QCar
  
例程如下图,将程序烧录进Micro:Bit,将Micro:Bit与Q-Car连接,Q-Car上的10颗WS2812B彩灯将同时以1800ms一周期循环彩虹光效
+
The routine is as shown in the figure below. The program is burned into the Micro: BIT, and the Micro: BIT is connected to the Q-CAR. The 10 WS2812B lights on the Q-CAR will simultaneously cycle the rainbow light effect with 1800ms
  
 
[[Image:Q-Car_Pixel.png]]
 
[[Image:Q-Car_Pixel.png]]
  
例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-Car_Pixel.hex
+
Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-Car_Pixel.hex
  
项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行
+
The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly
  
==超声波传感器控制==
+
==Ultrasonic sensor control==
  
学习目标:用MakeCode编程实现对Q-Car上HC-SR04超声波扩展模块的控制
+
Learning Objectives: Using Makecode programming to control the HC-SR04 ultrasonic extension module on BPI-QCar
  
例程如下图,将程序烧录进Micro:Bit,将Micro:Bit与Q-Car连接,将HC-SR04超声波扩展模块与Q-Car连接,将5V电源与Q-Car连接
+
Routine as shown below, burn the program into Micro:BIT, connect Micro:BIT with BPI-QCar, connect HC-SR04 ultrasonic extension module with BPI-QCar, connect 5V power supply with BPI-QCar
  
 
[[Image:Q-car_Ultrasonic_ranging.png]]
 
[[Image:Q-car_Ultrasonic_ranging.png]]
  
可以从Micro:Bit的USB串口读取到超声波传感器检测到的距离以及Micro:Bit上的温度传感器数据,例程实现了对超声波传感器的温度校准
+
The distance detected by the ultrasonic sensor and the temperature sensor data on the Micro:Bit can be read from the USB serial port of the Micro:Bit. The temperature calibration of the ultrasonic sensor is realized by the routine
  
 
Distance=85.815|Temperature=21
 
Distance=85.815|Temperature=21
  
例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-car_Ultrasonic_ranging.hex
+
Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-car_Ultrasonic_ranging.hex
  
项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行
+
The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly
  
==蜂鸣器的使用==
+
==Use the buzzer==
  
学习目标:用MakeCode编程编写一段曲子并在Q-Car的蜂鸣器上播放
+
Learning Objectives: Write a piece of music with Makecode and play it on the BPI-QCar buzzer
  
例程如下图,将程序烧录进Micro:Bit,将Micro:Bit与Q-Car连接,Q-Car上的蜂鸣器将循环两次播放曲子
+
The routine is shown in the figure below. Burn the program into Micro:Bit, connect Micro:Bit to BPI-QCar, and the buzzer on BPI-QCar will play the song twice in a cycle
  
 
[[Image:Q-car_Music_Arrangement.png]]
 
[[Image:Q-car_Music_Arrangement.png]]
  
例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-car_Music_Arrangement.hex
+
Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-car_Music_Arrangement.hex
 +
 
 +
The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly
 +
 
 +
==Line patrol==
 +
 
 +
Learning Objectives: using makecode programming to realize BPI-QCar line patrol driving, line patrol infrared tube analog value calibration, ultrasonic ranging and parking in case of obstacles
 +
 
 +
Routine as shown in the figure below, the program burned into the Micro:Bit , will Micro:Bit Connect with BPI-QCar and turn on the power switch,
 +
 
 +
When the right arrow is displayed in the LED matrix, align the two infrared couplers at the bottom and front of the BPI-QCar horizontally and place them directly above the line inspection line,
 +
 
 +
Press button B and wait for the calibration procedure to be completed. The left arrow will be displayed on the LED matrix. At this time, the front of BPI-QCar will face the line direction,
 +
 
 +
Press button A, BPI-QCar will start to patrol the line. If the ultrasonic ranging module detects that there is an object with a distance of less than or equal to 10 cm in front of it, it will stop
 +
 
 +
[[Image:Q-car_Line_patrol.png]]
 +
 
 +
Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-car_Line_patrol.hex
  
项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行
+
The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly

Revision as of 20:54, 24 February 2021


About BPI-QCar

BPI Q-Car with micro:bit
BPI Q-Car with BPI-Bit
BPI-QCar with BPI-AI board

Banana PI BPI Q-Car,which is a robot focusing on maker education.Compatible with Web:Bit(BPI: Bit) and Micro:Bit development boards.Small car body, highly integrated functions, plug and play, can quickly children's attention, complete the quick start of graphics programming, cultivate independent thinking and logical thinking ability

Key Features

  • support Micro:bit, PBI:bit(Web:bit) and BPI-AI(WEB:AI) boards
  • support Makecode graphical programming(with micro:bit),support Webduino graphical programming(with BPI:bit),and it also support MicroPython arduino(Micro:bit/BPI:bit)
  • Compact body, strong integrity
  • N20 Miniature reducer
  • Infrared emission, infrared reception, line patrol, speed measurement, atmosphere lamp, I2C interface (support 3.3V and 5V), ultrasonic interface, buzzer, steering gear interface, needle row expansion port, expansion screw hole, etc...Fully functional, strong expansibility
  • Easy to use it.

BPI-QCar with BPI:Bit for Arduino IDE

Arduino is an open source electronic prototyping platform that is flexible and easy to use.With the help of the community, BPI: BIT can be programmed with the Arduino environment, which you can refer to in the tutorial BPI:bit_for_Arduino

Motor control

Learning Objectives: Master the basic motor control method of Q-CAR

Program effect display: car forward 1 second, stop 100ms, back 1 second, stop 100ms, left 1 second, stop 100ms, right turn 1 second, stop 100ms.

Q-Car Motor Test.gif

Arduino code link:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Motor_Demo

Ambient light control

Learning Objectives: To understand the basic usage of Q-CAR RGB atmosphere light

Program effect display: bottom RGB atmosphere light red, green, blue three color mixing gradient display a variety of colors, showing a color breathing effect.

Q-Car Pixel Test.gif

Arduino code link:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Pixel_Demo

Ultrasonic sensor control

Learning objective: master the use of Q-CAR ultrasonic sensor

Program effect display: serial port display ultrasonic measured distance data.

Q-Car Ultrasonic Test 1.gif

Q-Car Ultrasonic Test 2.png

Arduino code link:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Ultrasonic_Demo

How to use buzzer

Learning objective: master the use of BPI-QCAR buzzer

Program effect display: the buzzer play "little star music"

Arduino code link:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Buzzer_Demo

IR control

Objective: To master the infrared remote control of Q-CAR

Program effect display: infrared remote control Q-CAR forward and backward and turn

Q-Car IR Control.gif

Arduino code link:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/IR_Control_Demo

Ultrasonic obstacle avoidance

Program effect display: boot the car forward, ultrasonic detection of the front distance, if the distance is less than 8cm, the car left and right to check the obstacles on both sides, choose the direction of the farther distance to turn, to avoid obstacles.

Parts preparation: M2 copper column ×2, M2 screw ×2, SR04 ultrasonic module ×1, ultrasonic bracket ×1, steering gear bracket ×1(Download address of bracket),DuPont line number, insert SR04 interface in front。

Q-Car Avoidance Demo.gif

Arduino code link:https://github.com/BPI-STEAM/Q-Car/tree/master/SoftWare/Web_Bit_Arduino/Avoidance_Demo

Line patrol

BPI-QCar with BPI:Bit use MicroPython

BPI-QCar with Micro:Bit use MakeCode

MakeCode programming to light up the LED on Micro:Bit

Learning Objectives: Familiarize yourself with basic Makecode applications and display some graphics or text on the Micro:Bit 5*5LED matrix.

Open the Makecode programming environment web side of Micro:Bit:https://makecode.microbit.org/

Create a new project and connect the Makecode blocks with the following routine. For example, the first block "Show Leds" can be found in the "Basic" options column. This block can edit the desired graphics

Microbit-screenshot (display graphics).png

Right-click building blocks to carry out some operations on the building blocks, such as add notes, delete copy building blocks, as well as access to the corresponding documentation of the building blocks, this for the first time people can provide great help.

The MakeCode programming environment has an emulator with its own simulation of the program to view the effect in real time, usually displayed at the top left

The Makecode programming environment also supports importing project files from outside, such as.hex files that are compiled by Makecode

Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-display-graphics.hex

Note:The correct way to import *.hex file is to download the.hex file from the link above and then import it into the MakeCode, rather than directly importing the link. External project links import the MakeCode differently

Makecode(import file).png

The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly

Micro:bit's Button control - Base

Learning Objectives: Use the two buttons A/B on Micro:Bit to control the graphics to be output by the LED matrix

On the basis of the section "Using Makecode Programming to Light Micro:Bit", find the building block "On Button A Pressed" in the "Input" option column of Makecode to program

The routine is shown in the figure below. Press the A button to display the English character "A", press the B button to display the English character "B", and press the AB button to display A pattern shaped like A banana

Using the button.png

Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Using_the_button_1.hex

The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly

Micro:bit's Button control -advanced

Learning objectives: Makecode programming to achieve a count and display button control procedures

Building on the previous section, create a new variable called "A_was_pressed_times" in the "Variables" section of the Makecode. This will generate multiple building blocks for the variable in the "Variables" section

Combine the addition blocks in the "Math" TAB and the Mosaic blocks in the "Variables" TAB. Refer to the following legend

Using the button 2.png

At this point, we realized in the Makecode programming and made A use of the addition counting program, press A button A count to add 1 at the same time the counting value output to the LED matrix, press A button B count to return to 0 and clear the LED matrix display

Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Using_the_button_2.hex

The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly

The wheel speed measurement

Learning Objectives: Using Makecode programming to read the high and low level signals of the infrared pair tube used for wheel speed measurement on BPI-QCAR and calculate the wheel speed with counting method

The routine is as shown in the figure below. The program is burned into Micro:bit, and the Micro:bit is connected to BPI-QCar. At this time, the left and right wheels of Q-CAR can be read from the USB serial port to the left and right wheel speed

Q-Car velocity measurement module.png

Q-Car velocity measurement module Serial port.png

Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-Car_velocity_measurement_module.hex

The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly

Motor control

Learning Objectives: Using Makecode programming to achieve QCar left and right motor forward and reverse control

Routines as shown in the figure below, the program is burned into the Micro: BIT, the Micro: BIT and Q-CAR connection, left and right motor will be turned to 2s at the same time, reverse 2s at the same time, right motor is turned to 2s alone, left motor is turned to 2s alone

Q-Car Motor control module.png

Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-Car_Motor_control_module.hex

The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly

Ambient light control

Learning Objectives: Use Makecode programming to control 10 WS2812B color atmosphere lamps on BPI-QCar

The routine is as shown in the figure below. The program is burned into the Micro: BIT, and the Micro: BIT is connected to the Q-CAR. The 10 WS2812B lights on the Q-CAR will simultaneously cycle the rainbow light effect with 1800ms

Q-Car Pixel.png

Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-Car_Pixel.hex

The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly

Ultrasonic sensor control

Learning Objectives: Using Makecode programming to control the HC-SR04 ultrasonic extension module on BPI-QCar

Routine as shown below, burn the program into Micro:BIT, connect Micro:BIT with BPI-QCar, connect HC-SR04 ultrasonic extension module with BPI-QCar, connect 5V power supply with BPI-QCar

Q-car Ultrasonic ranging.png

The distance detected by the ultrasonic sensor and the temperature sensor data on the Micro:Bit can be read from the USB serial port of the Micro:Bit. The temperature calibration of the ultrasonic sensor is realized by the routine

Distance=85.815|Temperature=21

Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-car_Ultrasonic_ranging.hex

The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly

Use the buzzer

Learning Objectives: Write a piece of music with Makecode and play it on the BPI-QCar buzzer

The routine is shown in the figure below. Burn the program into Micro:Bit, connect Micro:Bit to BPI-QCar, and the buzzer on BPI-QCar will play the song twice in a cycle

Q-car Music Arrangement.png

Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-car_Music_Arrangement.hex

The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly

Line patrol

Learning Objectives: using makecode programming to realize BPI-QCar line patrol driving, line patrol infrared tube analog value calibration, ultrasonic ranging and parking in case of obstacles

Routine as shown in the figure below, the program burned into the Micro:Bit , will Micro:Bit Connect with BPI-QCar and turn on the power switch,

When the right arrow is displayed in the LED matrix, align the two infrared couplers at the bottom and front of the BPI-QCar horizontally and place them directly above the line inspection line,

Press button B and wait for the calibration procedure to be completed. The left arrow will be displayed on the LED matrix. At this time, the front of BPI-QCar will face the line direction,

Press button A, BPI-QCar will start to patrol the line. If the ultrasonic ranging module detects that there is an object with a distance of less than or equal to 10 cm in front of it, it will stop

Q-car Line patrol.png

Routine project file:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-car_Line_patrol.hex

The project file can be imported into Makecode to view and edit after downloading to local, or it can be directly burned into Micro:Bit through USB and run directly