I'm developing an app in Visual Studio using C#. This app should be able to connect to a development board, by finding the COM port by itself. I'm using one of the answer of this post: How to auto-detect Arduino COM port? the one that use SerialPort.GetPortNames(). I tried to do stablish a connection, but it didn't work. The thing is I don't know if the problem is the code I use in the development board or it is other thing. The code uploaded to the board:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
establishContact();
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available() > 0){ //Check if the serial port is available
String inputRead = Serial.readString(); //Read what is entering on the port
}
}
void establishContact() {
while (Serial.available() <= 0) {
Serial.print('A'); // send a capital A
delay(300);
}
}
I'm kind of new to C# and arduino coding.
I have search but I didn't found anything. What I want is to establish a connection and then send data.