Right - where is the input for 'username' coming from? Your phone via the App?
username = Serial.readStringUntil('\n');
Was the input of the username five characters? What is the actual username that was typed-in? I think nothing was typed, but the read is executed and doesn't stop until '\n' - so memory is read, unrecognised characters, hence the ��
Edit: In other words, the code is reading User Input before the User has typed-in a name.
Concerning your App Inventor project, the Clock Timer is setup to constantly read from the moment the App is opened. It is also reading every 1 millisecond? You have one serial channel for read and write? That means you need an event for read and an event for send to ensure the two streams do not coincide.
No, it resets to the bootloader that waits for a new sketch. After a timeout it restarts the previous loaded sketch. (the same thing happens if you press the reset button, or starts the Arduino serial monitor)
Try the attached App Inventor Project. It isn't necessarily going to fix the sending of text to the terminal on first connection but it should prevent the App freezing from trying to send and receive at the same time.
Still the same, it seems to me that opening the show or initializing is still sending something. Or the arduino doesn't reset completely. When "clicking connect", it asks for permissions each time the program is restarted.
So modifying the program, how will I learn XD Because I would have to understand how EXACTLY the serial works. Then I would know what to modify. I was thinking about isAlphaNumerical () yet, but I can't program yet XD
The App (Serial OTG extension) isn't sending anything as far as I can tell, but the Sketch seems to run the loop prematurely. That's either a fault of the Sketch code or the chip bug mentioned before.
As Rolf Kardell (rkl099, extension developer) has said, Dtr can be used to reset the Arduino without flushing the existing Sketch. I don't know how to do this via the App, but the extension does have a Dtr function.
Try this Project (note, untested here as I do not have the hardware): A1_Test2.aia (194.4 KB)
Your program doesn't work, but it doesnt matter., I guess this DTR solves everything.
I installed the SerialOTG application and tried connections with and without DTR. So the DTR resets the board and when it connects, it normally asks for the nickname, but I need to find out if the DTR affects the operation yet, or should it be turned off while downloading and uploading data from and to the arduino. I do not know what the DTR really is, but I will read it in a moment. Sorry for english.
I do not understand what you mean. I look at the arduino and with the option enabled, the led "power" icon on the arduino goes off (that is, it resets during serial connection) when the DTR option is off the led does not go out. which sketch do you need?