hello again...
i just want to show you my edited code..this code will be able to access the switch button which is connected in arduino when i run the vb application..i just inserted your code RPCoyle in finding the commport...just take a look if what is lacking on this because i can only access the button switch but nothing sends to vb application or we may say the circle doesn't fill any color.... ![]()
Option Explicit
' this is added to allow the sleep call
Private Declare Sub Sleep Lib "kernel32" ( _
ByVal dwMilliseconds As Long)
Private Sub Form_Load()
Dim mystr As String
Dim FoundIt As Integer
Dim ComFail As Integer
Dim FailErr As Integer
Dim n As Integer
MSComm1.Settings = "9600,N,8,1"
FoundIt = False
' find USB port
ComFail = False
FailErr = False
For n = 1 To 1
If MSComm1.PortOpen Then MSComm1.PortOpen = False
On Error Resume Next
MSComm1.CommPort = 1
On Error Resume Next
'MSComm1.DTREnable = True
'MSComm1.RThreshold = 4
'MSComm1.SThreshold = 3
MSComm1.InputLen = 0
MSComm1.PortOpen = True
Next
End Sub
Private Sub LEDOn(col As Long)
Shape1.BackColor = col
End Sub
Private Sub LEDOff()
Shape1.BackColor = &HFFFFFF
End Sub
Private Sub MSComm1_OnComm()
Dim strData As String
Static strBuffer As String
Dim strWords() As String
Dim intPos As Integer
Dim boComplete As Boolean
Dim mystr As String
Sleep 1000 ' this waits one second between readings from the Arduino
mystr = "" ' set the string to nothing
mystr = MSComm1.Input
intPos = InStr(mystr, "<")
If intPos > 0 Then
Select Case Mid(mystr, 1, 3) ' strip off the CR/LF
Case "<Y>"
Text1.Text = ("The pressures value is 80 psi")
Call LEDOn(&HFFFF&) ' this is in hex
Case "<B>"
Text1.Text = ("The pressures value is 60 psi")
Call LEDOn(&HFF0000) ' this is in hex
Case "<R>"
Text1.Text = ("The pressures value is 20 psi")
Call LEDOn(&HFF&) ' this is in hex
Case "<G>"
Text1.Text = ("The pressures value is 40 psi")
Call LEDOn(&HFF00&) ' this is in hex
Case Else
Call LEDOff
End Select
End If
End Sub
thanks ![]()