Unable to connect Arduino Due to Winform C# via Serial Com
Hi all bro, I am trying to connect arduino due on winfrom c# to pc via Serial similar to connecting with arduino uno r3/mega 2560. but the result doesn't seem to work.
My program on c# connects fine to arduino r3 with the following commands:
serCOM.PortName = ... ;
serCOM.BaudRate = ... ;
serCOM.Open();
serCOM.WriteLine();
serCOM.Close();
//////////////
Please point out my mistake thanks, does the arduino due have a different serial connection than the arduino uno?
Blockquote
Arduino_due_xoay.ino (26.7 KB)
Winfrom C# program control Arduino Due.zip (772.9 KB)
Give more details:
- What were you expecting to happen?
- What actually happens?
- What investigation/testing/debugging have you done to find where it's going wrong?
In particular, what have you done to check if the problem is at the Arduino end, or the PC end?
Hey,
I picked up an Uno for a lockdown project. That went well and I've just bought a Arduino Due for more speed and memory. However the Serial communication code that worked fine with Uno/C# comms isn't working with Arduino Due/C# comms.
Using Serial.write on the Arduino Due will cause the output to appear in the Arduino IDE's Serial Monitor but C# won't find anything to read.
For a test I've stripped it down to this:
void setup() {
Serial.begin(9600);
while (!Serial) { }
}
void loop() {
Serial.write( "Hello World\n" );
delay( 1000 );
}
As expected, the Serial Monitor is full of "Hello World", but this test C# snippet gets nothing.
SerialPort serialPort = new SerialPort( "COM6", 9600 );
serialPort.Open();
while ( true )
{
Console.WriteLine( $"Received: {serialPort.ReadExisting()}" );
Thread.Sleep(1000);
}
Note: I do not have the Serial Monitor and the C# app trying to connect at the same time as I know that will cause problems.
Does the Arduino Due do something different with its Serial output that the monitor is aware of but I'm missing in my SerialPort setup in C#?
Any help would be much appreciated.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.