hello..
Private Sub Form_Load()
With MSComm1
If .PortOpen Then .PortOpen = False
.CommPort = 2 // i change the comport into 2 as what i had seen in serial monitor of arduino
.Settings = "9600,N,8,1"
.DTREnable = True
.RTSEnable = True
.RThreshold = 4
.SThreshold = 3
.PortOpen = True
End With
End Sub
RPCoyle, i used your code and yet it works but it goes back to the problem before that when i try to hit the switch button the Led connected in pin 9 will not light and so on...it seems nothing happens when i use to run the vb application..the communication between arduino to vb are not functioning or we may say that i can't access the input from arduino to vb...but if i try the code below:
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Sub MSComm1_OnComm()
Dim Str As String
MSComm1.Settings = "9600,N,8,1"
FoundIt = False
' find USB port
ComFail = False
FailErr = False
For n = 1 To 16
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
On Error Resume Next
MSComm1.CommPort = n
On Error Resume Next
MSComm1.InputLen = 0
MSComm1.PortOpen = True
If MSComm1.CommID > 0 Then
strt = InStr(Str, "<") + 1
fin = InStr(Str, ">")
If (fin - start) <= 0 Then
Else: ColorStr = Mid(Str, start, (fin - strt))
End If
If MSComm1.PortOpen = False Then MsgBox "Controller Not functioning , Please check USB connection", vbCritical, "": ComFail = True: Exit Sub
jump:
' your case statement
' Debug.Print ">"; Str; "<";
Select Case (Str) ' set a break point here so you can step through the case statement
Case "A"
Call LEDOn(vbRed)
Case "B"
Call LEDOn(vbGreen)
Case "C"
Call LEDOn(vbBlue)
Case "D"
Call LEDOn(vbYellow)
Case Else
Call LEDOff
End Select
End If
'Exit Function
End Sub
Private Sub LEDOn(col As Long)
Shape1.FillColor = col
End Sub
Private Sub LEDOff()
Shape1.FillColor = vbWhite
End Sub
i can access the input from arduino when i run the vb application..