Go Down

Topic: arduino+vb6 (Read 9 times) previous topic - next topic

dxw00d


Glennmars

yeah, i feel sorry for this..then, let's merged them..
sorry for this inconvenience becausei don't know how to link the two.. ;)

RPCoyle

try this ...
Code: [Select]

' set up for the input....

str = MSComm1.Input  ' get the string
str = Left(str,1)  ' chops off the first char
Debug.Print ">"  str  "<"  ' now you can see what is comming through in the immediate window of VB
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

'on the Arduino side just send out:

'Serial.println("A")

'why send out a whole line of text if you don't need it

Glennmars

thanks RPCoyle  for your suggestions :%

i tried the code but still nothing sends to the vb.. :smiley-roll-blue:


RPCoyle

You may be finding the wrong com port. You have COM1  hardwired into the VB code.

You need to look at what the Arduino IDE is using for your board and use that instead

The code below is what I use to make sure that I am seeing output from my board. It look for a specific string input and then selects that COM port

You can tweak the code to give you what you want

Code: [Select]

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
     For i = 1 To 100
      str = ""
      str = MSComm1.Input
      If InStr(str, "<") > 0 And InStr(str, ">") > 0 Then GoTo  jump: ' in this case the output from Your Arduino  would be "< R >" or  "< Y >" of < G > "....
      Sleep 50
     Next i
  End If
Next n
If MSComm1.PortOpen = False Then MsgBox "Controller Not functioning , Please check USB connection", vbCritical, "": ComFail = True: Exit Sub

jump:
     '   your case statement

Go Up