Go Down

Topic: cannot read the data from arduino to the c# (Read 5 times) previous topic - next topic


PaulS

This is what the first part of my connect button's callback code looks like:
Code: [Select]
private void connect_Click(object sender, EventArgs e)
{
System.ComponentModel.IContainer components =
new System.ComponentModel.Container();
port = new System.IO.Ports.SerialPort(components);
port.PortName = comPort.SelectedItem.ToString();
port.BaudRate = Int32.Parse(baudRate.SelectedItem.ToString());
port.DtrEnable = true;
port.ReadTimeout = 5000;
port.WriteTimeout = 500;
port.Open();

The form has drop down lists for the com port and baud rate.

With this code, I'm able to send to/read from all the Arduinos I have (Mega, Leonardo, and Duemilanove).

(port is a global instance of the SerialPort class.)

arduino_learners

so the coding for writeline and readline cannot read the data from arduino?

PaulS

Quote
so the coding for writeline and readline cannot read the data from arduino?

I don't understand this statement/question. Of course it is possible to write to the serial port that the Arduino is connected to, and read from that serial port.

Of course, the Arduino must be sending data for there to be something to read and the Arduino must be reading the data for there to be a reason to send it.

You seem to have nothing on the PC end more than an echoer of what the Arduino sent, so, how do you know it isn't working?

arduino_learners

i am able to receive the da ta on the arduino because i have check it using the SerialMonitor of the arduino.however, i cannot get those data received to be transferred to  my GUI using c#.nothing appeared on the GUI side.

Go Up