VB to send command to arduino

hi kids

I'm not an expert at all, but I can tell you what I did, and some of the thoughts I had.

If you havn't found out yet .. pick a serial port in the toolbox and drop it on your form.
Doubleclick the icon and .. voila, you are i the event that responds when bytes comes back from the arduino.
I hope that you've found out, that vb is event-driven, and that the code-'cursor' flutters around between the events that occurs .. thats my way of thinking about it.
The serial port you just dumped may not know about the port you use, so I put this code in the form 'new' procedure:

Public Sub New()

InitializeComponent()

For Each p In My.Computer.Ports.SerialPortNames
If p = "COM15" Then
SerialPort1 = My.Computer.Ports.OpenSerialPort("COM15")
SerialPort1.Encoding = New System.Text.ASCIIEncoding
If Not SerialPort1.IsOpen = True Then
SerialPort1.Open()
End If
End If
Next
.....

I've chosen ASCII becourse it's a one byte encoding [edit:no, it's 2 bytes] (you'll have to get to grips with encodings sooner or later). I recall, that the Port didn't always read all the code that came from the controller .. that's where it's handy to be able to rely on just 1 'message'-bite. Alternatively the SerialPort1.ReadExisting can be used. The sort of 'encoding' you choose for yourself doesn't matter .. the important thing is, that YOU understand it.

In the code-editor you can find "SerialPort1" in the left drop-down menu. Once you've picked it there, you may look at it's 'events' in the right drop-down menu. There's an 'errorRecieved' that may come in handy.

And when you've collected something to send .. SerialPort1.Write(..). You'll probably place it in a button-click event.

have fun