loading

Can you control an Arduino with Visual Basic?

If it is posible could some awesome person give me the code for Visual basic express to light a light on the arduino by clicking on a button in VB I am trying to control a vecial that has alot of motors and sensors so i thought to use an ardoino instead of a 20 wire teather. It wil stil hfave a teather but it will only be a USB wire. Thanks!!!!!!!!!!!!!

sort by: active | newest | oldest
If you look at my blog, I have written a basic command interpreter for Leonardo boards which understands simple commands such as dout 13 1 (set digital input 13 high). These commands can be sent to an Arduino board over a serial linkfrom a serial terminal program running on a PC such as hyperterminal, Realterm or Procomm. I have also written a program for VB which allows you to click buttons to set inputs high or low. See http://eugbugino.blogspot.com where you can download the code free.
Eugbug,
Thank you for the answer and drawing my attention to this question.
Ma77h3w8 years ago
my dissertation involved controlling a robot via serial port. so it should work. I used VB 6 (old one) cause it comes with the MSCOMM32.OCX component (project -> components) then code such as this to send and recieve to the serial port.

'SETUP
With MSComm1 'sets up COM settings
.Handshaking = 0
.RThreshold = 0
.RTSEnable = False
.CommPort = 3
.Settings = "115200,n,8,1"
.SThreshold = 0
'.PortOpen = True
End With

'RECIEVE
Private Sub MSComm1_OnComm() 'Triggered automatically each time COM port event
Dim InBuff As String
Select Case MSComm1.CommEvent
Case comEvReceive ' Received RThreshold # of chars.
InBuff = MSComm1.Input
Call HandleInput(InBuff) 'Buffer gets examined by HandleInput function
End Select
End Sub

'TRANSMIT
MSComm1.Output = "Hello World" + Chr(13)
Ma77h3w Ma77h3w8 years ago
P.S it's possible to get the MSCOMM.OCX working on the newer VB versions.. but it's difficult.. google it!
frollard8 years ago
The arduino 'talks' serial - you just need to program the arduino environment to listen for a set of commands - theres lots of robot code on the arduino.cc forums. Then with vb.net/basic/express - you just need a program that sends serial commands over the virtual serial port created when you plug the usb in. It'll be configured the same as the arduino sketch editor (same serial settings). In fact, once configured, a sketch can just listen for serial, and you can connect with the terminal and type commands to the terminal to communicate with the arduino. The next step could be adding a bluetooth or xbee radio to the arduino (also emulating a serial port) and lose the tether completely. Read the arduino beginner tutorials on ladyada's site and arduino.cc
Pyrotechnic-Robot (author)  frollard8 years ago
Thanks!
I figured out some things but I have a few other questions.
How make the arduino to listen to commands from VB?
This is what I have in VB.
I can get the mouse controls working but not the keyboard
THANKYOU SO MUCH!!!!!!!!!
Public Class Form1

Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
If e.KeyCode = Keys.W Then
Button1.BackColor = Color.Empty
????????
End If

If e.KeyCode = Keys.S Then
Button2.BackColor = Color.Empty
????????
End If
End Sub

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.W Then
Button1.BackColor = Color.LightGray
????????
End If

If e.KeyCode = Keys.S Then
Button2.BackColor = Color.LightGray
????????)
End If
End Sub

End Class
I forget all the vb - you need some vb code that opens and communicates with a serial port. - the same way that the arduino ide connects, the same way you'd connect with any serial program. Plugging the arduino in with usb makes a serial port appear on the computer.