Hey guys, Hope this is the right forum for this. I have an arduino uno board that is sending me analog values over serial to a vb 2010 program I am writing. What I am trying to do is have a progress bar, and a text box show the current value. I have it working except that the whole program is very slow to update the values, and I cannot close the program except through the stop debugging in VB. If I comment out the following code the program runs, and closes fine. Also it keeps warning me about threading cross calls....I didn't even know there was threading going on. I certainly have no thread calls in the code. Here is the code that I have:
Code:
Private Sub SerialPort_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort3.DataReceived
Dim data As String = SerialPort3.ReadLine()
ReceivedText(data)
End Sub
Private Sub ReceivedText(ByVal [data] As String)
If Me.TextBox1.InvokeRequired Then
Dim x As New SetTextCallBack(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(data)})
Else
If IsNumeric(data) Then
Dim val As New Decimal
val = CType(data, Decimal)
val = val * 0.1
If (val < 40.1 And val > 19.9) Then
TextBox1.Text = val
ProgressBar1.Value = val
End If
End If
End If
End Sub