Arduino + VB.net 2010

Hello,

I'm currently working on a Visual Basic interface with my arduino. Using SerialCommunication, I'm transmiting number to the arduino from the computer to command the arduino. Really simple when it's come to command Digital output.

But where I've some problems is when I want my computer know when A voltage is apply on the Pin 2 of my arduino. Actually, when I'm applying the voltage on Pin2 my arduino send, one time only, the number "51" in com port. When I disconnect the voltage, my arduino send "50" in the com port.

With this, I want my Visual Basic software write "On" when he got the "51" and "Off" when he receive "50".

I've put a Timer in my software to read the com port at every milli-seconds with the command "s.readLine". But when I activate this timer, my software get stuck in this operation. He can't do anything else.

here is my timer code (my variable is COR) :

COR = s.ReadLine
If COR = 51 Then
Label1.Text = "On"
Else If COR = 50 Then
Label1.Text = "Off"
End If

Is there any way to program my software to not getting stuck in the operation ?

I hope you understand what I mean. If you won't, don't be shy to ask me for more details ^^ Thanks in advance!

I think you need to look at comm events. I have never used VB.net 2010 but a quick look on the net makes me think you should look at SerialPort1_DataReceived. This is called when data is received on the com port. If you put your code in this event it should only be activated when data is received.

You may want to look up DataReceived and see how its used.

Hope this helps

Rob

Actually, when I'm applying the voltage on Pin2 my arduino send, one time only, the number "51" in com port. When I disconnect the voltage, my arduino send "50" in the com port.

The value 51 is the ASCII code for '2'. The value "50" is the ASCII code for '1'. It's much better to write code based on '1' and '2' than 50 and 51.