Self-made APP Inventor Bluetooth data receiving template is the only way to self-made remote control car App~

App Inventor 2 WxiBit Chinese Enhanced Edition Bluetooth Receive Data Receive Template

I have written a lot of articles about Arduino hardware, there are also Internet of Things and PID. Let’s share the software and introduce the platform we use. App Inventor 2 WxiBit Chinese enhanced version is an Android App development platform developed and maintained by Mr. Yang Daoquan from South China University of Technology. More powerful functions, need to master JAVA and more difficult to operate Android Studio, even C language foundation does not need to have App Inventor with rich functions Modular programming is a very good choice for most of our students. The most convenient way for unlimited communication with the single-chip microcomputer is to use the Bluetooth module. Now the Bluetooth that everyone uses is generally divided into two types. The first is the classic Bluetooth and the corresponding is our very commonly used HC-05 HC-06 module. The second is the BLE Bluetooth. There is a certain difference between the two ways of using Bluetooth for modules above HC-08. The template introduced here today is used to use classic Bluetooth and will be BLE Bluetooth.
You can go directly to the exhibition hall to search for the classic bluetooth data receiving and sending template, which I sent to the exhibition hall. Just find the project and copy it directly, or you can import the project template in the following way

1. App Inventor 2 WxiBit Chinese Enhanced Edition project import and export function introduction

Template link self- selection
Link: template link .
Extraction code: wy4a

Insert picture description here
Click Import Project,
Insert picture description here
find the project file with the suffix aia, click open,
Insert picture description here
select OK

Insert picture description here
Waiting for the import to complete
Insert picture description here
, transfer the previously completed project to its own project list
Insert picture description here

2. Introduction to APP Inventor bluetooth receiving data receiving template function

2.1Acitvity launcher detects Bluetooth enabled status

When we use the Bluetooth serial debugging assistant, if you don’t turn on Bluetooth when you open the app, the app will remind you whether you want to turn on Bluetooth. The same function is available in our template app.
Insert picture description here
If you click on it, you can check it in the app. Turn on the Bluetooth button to recall the function

2.2 Link Bluetooth

Classic Bluetooth must be paired before use. Find the Bluetooth module and click on the Bluetooth operation interface of the phone. Generally, the pairing password is 1234. After the
Insert picture description here
pairing is successful, the phone will prompt that the device is paired. Insert picture description here
Then open the APP and click to select the Bluetooth. The
Insert picture description here
list will show that you can Linked Bluetooth address, click the link. After the
Insert picture description here
link is successful, the Bluetooth status will be displayed to link to the Bluetooth, and the communication with the microcontroller can be realized
Insert picture description here

2.3 The function of registering the linked Bluetooth address

When the Bluetooth address has been successfully connected once before, when the
APP is reopened, the connected Bluetooth address will be displayed. At this time, there is no need to select Bluetooth again. Just the motor link Bluetooth button can directly link to the Bluetooth according to the last address.
Insert picture description here

2.4 Arduino UNO simple communication simulation experiment

Experiment preparation
1. Arduino UNO 2.
HC-05 HC-06 Bluetooth module
3. Dupont cable The
wiring diagram is shown in the figure and the
Insert picture description here
test code is as follows

String My_String;
void setup() 
{
    
    
  Serial.begin(9600);
  Serial.println("测试开始");
}

void loop() 
{
    
    
 while(Serial.available()>0)
 {
    
    
  My_String=Serial.readString();
  Serial.println(My_String);
 }
}

After the Bluetooth connection is complete, enter I love you in the input text box and click Send. The
Insert picture description here
serial port is displayed as follows, and at the same time, UNO's serial port printing is equivalent to sending the received information back to the APP, so the information received by the APP also shows I love you
Insert picture description here
Insert picture description here

to sum up

This is an introduction to the use of template functions, so there is no introduction to the code blocks that implement its functions, but after you go back and import the project, you can study and study the following code blocks by yourself, and you can modify them yourself. I originally wanted to make a small car. The remote control template, but I think it is still a Bluetooth receiving and sending message. You can try to change it when you go back.

Guess you like

Origin blog.csdn.net/chrnhao/article/details/112758514