Go Down

Topic: Problem with .net and serial ports (Read 491 times) previous topic - next topic

Werni

Hi
I have a problem with a program written in vb and the Arduino.
The communication does not work.
The LED shows, that the computer sends characters to the Arduino.
However, from there, nothing comes back.
But with the Arduino IDE everything works fine.

Here's the code:
void setup () {Serial.begin (9600);}

void loop () {
  if (Serial.available> 0) {
   Serial.println (Serial.read ());
  }
}


Dim serial as new IO.SerialPort
serial.Portname = "COM12"
serial.open ()

serial.send ("A")
msgbox (Serial.readline ())

The strange thing is that the code used to work. Only after restarting the computer nothing worked anymore.

Please help,
best regards
Werni

focalist

Did the serial port get redefined on the reboot?  Check device manager.
When the testing is complete there will be... cake.

MikMo

You are not setting the Baud rate and other vital parametres of the serial port in your VB code.

Also you are not waiting just a little moment before trying to read the answer from Arduino. The PC is much faster than Arduino so you can not expect the anwer to appear instantly.

But i it has worked before it is likely that Focalsit is right, your serial port is anoter now, this happen sometimes.

PaulS

There are issues with some PC code when referring to COM port numbers greater than 9. Some goofy combination of dots and slashes is required on brain-dead Windows systems.

Search Microslops' web site or this forum for "COM port greater than 9" for details. Or kill whatever it is on your computer is using up all the lower port numbers. My PC never assigns my Arduino a number higher than 6, and it only goes that high when I have 3 Arduinos connected at once.

Go Up