Here is my Situation. I want to create a GUI in VB.net which contains only one textbox and a button. Whenever i enter any string in a textbox and press the button, the Arduino connected to PC with USB should be able to receive that value and then should be able to send that value to my other module using Zigbee.
I have successfully done LED test using the hardcoded values in Arduino, but now i want a user input.
In VB.net there's a serial port class. Initialize an instance of it with the correct parameters and you can send data to Arduino.
On the Arduino side you use the serial.available() and serial.read() functions.
This is (part of) the vb.net code i use to open a serial port.
Imports System.IO
Dim WithEvents serialPort As New IO.Ports.SerialPort
Public Sub serialPortOpen()
'Configure and open the serial port
'If the port is already open, close it first
If serialPort.IsOpen Then
serialPort.Close()
End If
Try
With serialPort
.PortName = "your serial port goes here i.e com2 or whatever"
.BaudRate =9600 'must match what you setup in your arduino code
.Encoding = System.Text.Encoding.ASCII
.NewLine = Chr(13) + Chr(10)
End With
'Open the port and clear any junck in the input buffer
serialPort.Open()
serialPort.DiscardInBuffer()
Catch Ex As Exception
'handle any errors here
End Try
End Sub
If you are only going to send data frm VB to Arduino i think you can skip "withevents" in port declaration, but if you want to use for instance the serialport.ondatarecieved event it must be there.
thanks for the reply. So you are suggesting, that using VB.net first i write something on the Serial port which Arduino will read using Serial.read() and then i write on Serial port using Serial.write() in Arduino which is transferred to Other Device using Zigbee right?
Thats one possible way of doing it. But i think it moght be possible to connect the Xbee directly to the PC. I have no practical experince with Zigbee / Xbee modules, but i remember from another thread in here that it was suggested that the Xbee module could be connected directly to the PC. but you should get "a second opinion" on that.
i remember from another thread in here that it was suggested that the Xbee module could be connected directly to the PC. but you should get "a second opinion" on that.
Not directly to the PC, but using one of these works:
I have already got 2 of these. Do i need to configure this device or it is simply to take an input from Serial and broadcast it? I try to get a simple serial input from that and do a LED test and will get back here with a feedback.
I have successfully programmed Xbee with Xbee Shield. Its not that difficult, as PaulS said, Xbee are already configured, so what you have to do is just program the serial port in VB.net to read and write and Xbee will do the rest automatically.
Now i can easily send Strings from one Xbee connected to PC using USB cable to another Xbee connected to another PC using USB cable.