[ACM32F070 supporting capacitive touch development board target -- Arduino preparation for dual-machine UART communication linkage]
[Copy link]
This post was last edited by JohnMatthrew on 2022-11-5 23:30
It was a very pleasant experience, and it was easy to get started with this development board. Although I have used STM32, I usually do pure hardware development and use it less. (An employee of a new energy vehicle company, haha) As the supervisor of the main drive hardware project, I am very busy. I do everything in my spare time. I have been working hard and have done the verification. After the verification is done, I will share it with everyone. After a period of learning and experiencing the Hangxin ACM32F070 kit development board, the experience is almost over. At this time, I have to come up with some dry goods, which corresponds to my evaluation theme, so please link it with the Arduino serial communication.
Let me share with you the materials used:
1. A set of capacitive touch development board for Hangxin ACM32F070 (which is our great application evaluation tool)
2、Arduino Pro mini
3. A CH340G downloader (mainly for burning programs to Arduino and testing the serial port's sending and receiving)
4. A PC (for writing code and debugging)
First, I used my Pro mini to write the code and reserve some information needed for our serial port. In this issue, I will first plan our functional blueprint.
The simplest way to highlight our capacitive touch is to assign values to the up, down, left, and right buttons respectively, and press the corresponding button to send the corresponding character.
Up----- a
Next -------b
Left --------c
Right---------d
Assign the values separately. After receiving, let Arduino return 1 (received)
So, how do you write Arduino code? Start typing the code.
First start initialization:
void setup()
{
// Flash a light during initialization
digitalWrite(13,HIGH);
delay(100);
digitalWrite(13,LOW);
delay(100);
//Set the baud rate of the serial port to ensure that everyone can chat at the same frequency
Serial.begin(115200);
Serial.print("initialize OK");
delay(10);
}
This completes the initialization settings. The next step is the hard work. However, I think it is better to do simple things simply, and one round of string recognition is enough. Before this, add the global variable String temp to the beginning, which is the safest way to do the content received by the serial port.
Next to the loop content:
void loop(){
//First, let our serial port receive things normally, then arrange recognition, and wait a while before recognizing after receiving.
if(Serial.available()>0)
{
delay(20);
temp = Serial.readString();
//Next, the judgment starts. As long as one of abcd is sent, it will reply 1
//Adhering to the attitude of open source, I will release the key code hahaha, but I will post the specific source code on my Gitlab or Github, everyone is welcome to get it
if(temp=="a"){
digitalWrite(13,HIGH);
delay(50);
digitalWrite(13,LOW);
delay(50);
Serial.print("1");
}
Prepare the contents abcd in sequence, all of which are reply 1. If you want to change to something else, it doesn’t matter, just modify the code.
I'll show you the video overview. I'll burn the code into Arduino and verify it with the serial debugging assistant. Everything is OK. Once you send one of the characters abcd, reply 1
After that, I will finish the next phase and prepare the aviation core kit.
Make arrangements hahaha
|