Getting Started with BPI-QCar

From Banana Pi Wiki
Revision as of 01:59, 24 February 2021 by Sinovoip (talk | contribs) (MakeCode programming light Micro:Bit Led)
Jump to: navigation, search


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

巡线行驶

BPI-QCar with BPI:Bit use MicroPython

BPI-QCare with Micro:Bit use MakeCode

MakeCode programming light Micro:Bit Led

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 to Micro:Bit through USB and run directly

按钮控制Micro:Bit-基础

学习目标:使用Micro:Bit上的AB两个按钮控制LED矩阵所要输出的图形

在章节“使用MakeCode编程点亮Micro:Bit”的基础上,在MakeCode中“input”选项栏目中找到应用按钮控制的积木“on button A pressed”来进行编程

例程如下图,实现按一下A按钮显示英文字符“A”,按一下B按钮显示英文字符“B”,同时按下AB按钮后显示一个形似香蕉的图案

Using the button.png

例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Using_the_button_1.hex

项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行

按钮控制Micro:Bit-进阶

学习目标:用MakeCode编程实现一个计数并显示的按钮控制程序

在前一章节的基础上,先在MakeCode中“Variables”选项栏目中新建一个变量名为“A_was_pressed_times”的变量,此时将在“Variables”选项栏目产生多个关于变量的积木

将“Math”选项栏目中的加法积木与“Variables”选项栏目中的积木镶嵌组合,参照下图例程

Using the button 2.png

此时,我们就实现了在MakeCode编程并做出了一个利用加法计数的程序,按一次按钮A计数加1同时将计数值输出到LED矩阵中,按一次按钮B计数归0并清除LED矩阵的显示

例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Using_the_button_2.hex

项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行

车轮测速

学习目标:用MakeCode编程实现读取Q-Car上用于车轮测速的红外对管的高低电平信号并用计数法算出车轮转速

例程如下图,将程序烧录进Micro:Bit,将Micro:Bit与Q-Car连接,此时旋转Q-Car左右轮,可以从USB串口中读取到左右轮转速

Q-Car velocity measurement module.png

Q-Car velocity measurement module Serial port.png

例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-Car_velocity_measurement_module.hex

项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行

电机控制

学习目标:用MakeCode编程实现Q-Car左右电机正反转控制

例程如下图,将程序烧录进Micro:Bit,将Micro:Bit与Q-Car连接,左右电机将同时正转2s,同时反转2s,右电机单独正转2s,左电机单独正转2s

Q-Car Motor control module.png

例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-Car_Motor_control_module.hex

项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行

氛围灯控制

学习目标:用MakeCode编程实现对Q-Car上10颗WS2812B彩色氛围灯的控制

例程如下图,将程序烧录进Micro:Bit,将Micro:Bit与Q-Car连接,Q-Car上的10颗WS2812B彩灯将同时以1800ms一周期循环彩虹光效

Q-Car Pixel.png

例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-Car_Pixel.hex

项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行

超声波传感器控制

学习目标:用MakeCode编程实现对Q-Car上HC-SR04超声波扩展模块的控制

例程如下图,将程序烧录进Micro:Bit,将Micro:Bit与Q-Car连接,将HC-SR04超声波扩展模块与Q-Car连接,将5V电源与Q-Car连接

Q-car Ultrasonic ranging.png

可以从Micro:Bit的USB串口读取到超声波传感器检测到的距离以及Micro:Bit上的温度传感器数据,例程实现了对超声波传感器的温度校准

Distance=85.815|Temperature=21

例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-car_Ultrasonic_ranging.hex

项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行

蜂鸣器的使用

学习目标:用MakeCode编程编写一段曲子并在Q-Car的蜂鸣器上播放

例程如下图,将程序烧录进Micro:Bit,将Micro:Bit与Q-Car连接,Q-Car上的蜂鸣器将循环两次播放曲子

Q-car Music Arrangement.png

例程项目文件:https://github.com/Wind-stormger/Makecode/blob/master/microbit-Q-car_Music_Arrangement.hex

项目文件下载到本地后可导入MakeCode中查看和再编辑,也可直接通过USB烧录到Micro:Bit中直接运行