Pages: [1]   Go Down
Author Topic: Problem with .net and serial ports  (Read 449 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Boston Suburbs
Offline Offline
God Member
*****
Karma: 16
Posts: 955
I am above your silly so-called "Laws", Mister Ohm.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Did the serial port get redefined on the reboot?  Check device manager.
Logged

When the testing is complete there will be... cake.

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49040
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: