Thank you. When you have time, please try:
1 - Use the back button to leave the app while serial is connected.
2 - Remove the USB cable when serial is connected.
These two situations lead to the app crashing. If I use the other buttons (circle and square) to hide the app, it won’t crash and it will work after I launch it again.
Sure, here is the Arduino Test Code. The board I am using is a ESP32-C3 Super Mini, and it connects via USB OTG cable to my phone. Basically just USB serial happening between phone and ESP32. The board is also powered by the phone via the USB connection:
#define LED_1_PIN 9
#define LED_2_PIN 10
uint8_t Volume = 0;
uint8_t Gain = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(LED_1_PIN, OUTPUT);
pinMode(LED_2_PIN, OUTPUT);
analogWrite(LED_1_PIN, 0);
analogWrite(LED_2_PIN, 0);
}
void loop() {
String inData;
bool Get_Data = false;
// bool CheckConnection = false;
if (Serial.available() > 0) {
inData = Serial.readStringUntil('\n');
if (inData.equals("Volume")) {
Get_Data = true;
while (Get_Data) {
if (Serial.available() > 0) {
inData = Serial.readStringUntil('\n');
Volume = inData.toInt();
analogWrite(LED_1_PIN, Volume);
Get_Data = false;
inData = "";
}
}
}
if (inData.equals("Gain")) {
Get_Data = true;
while (Get_Data) {
if (Serial.available() > 0) {
inData = Serial.readStringUntil('\n');
Gain = inData.toInt();
analogWrite(LED_2_PIN, Gain);
Get_Data = false;
inData = "";
}
}
}
}
}