I am trying to communicate with the Arduino board using the serialport function in VB.NET. I want to create a program that can enable the digital input pins on the arduino, so I plan on sending a 1 through 13 to the board and have code in the arduino read a value from the serial port and appropriately turn on the pin that is requested by VB.NET.
My problem is as follows:
I try to send a 1 to the arduino, and when I monitor the COM3 port the following appears,
Port opened by process "Serial Tester.vshost.exe" (PID: 5712)
01 01 ..
The "01" appears and to the right in a different column a "." appears as you see.
When I send a 50, this is what I monitor
Port opened by process "Serial Tester.vshost.exe" (PID: 5712)
0D 0D ..
I see that VB.NET sends a hex value instead of an integer. But what is that "." on the right column?
Now my question is when I try to receive the value and print it using the arduino decimila, it does not print it to the serial port. The RX and TX lights flash but it does not print.
If I send a value less than 10 the value is an integer and hot a hex value, so the board should be able to use it as an int and print it out, but it does not.
I know that the board works because when I use HyperTerminal the board is able to take a key press and print the value of it.
How do I get visual basic to send a number, (1 through 13) to the arduino so it can use it?
I'm working on a VB .net app. too. i would be very interested in sharing experinces.
My app is mostly listening for incoming data from the Arduino board, and i did not have to change any encoding settings to read the incoming data (integer values) correctly.
I found a small VB example program on the net, kind of a chat program working over the serial line, that i was able to modify to read from the arduino board.
The issues i found is with threading. I seems that the code taht makes up the eventhandler listening for incoming data and triggering the recieved event is running in one thread and the user interface components in another and you can't just do stuff across these thread boundries.
So from the recieved event handler you cant update say a textbox in a window directly. You have to use a delegate.
My understanding of delagates in .net is somewhat flakey, but i managed to make it work. I read the values of 16 potentiometers on the Arduino board, and send them as comma seperated values followed by a CR LF, so i can read all the values as one line in the VB app. For now all i do is display them in 16 label controls in a window.
Hey,
I see I am not the only one who is trying it's luck with VB. I've made a program that feeds a MySql database with sensoric input from the Arduino. The program searches the arduino and when found it keeps listining for input from the arduino. When senoric data comes in it's directly pushed to the database.
The only thing I am not familiar with is the use of char variables for string makeup. I am trying to construct a string of different char variables but I am missing out an something I guess.
It needs to be a comma seperated string just like above here : is explained.
Hey,
I see I am not the only one who is trying it's luck with VB. I've made a program that feeds a MySql database with sensoric input from the Arduino. The program searches the arduino and when found it keeps listining for input from the arduino. When senoric data comes in it's directly pushed to the database.
The only thing I am not familiar with is the use of char variables for string makeup. I am trying to construct a string of different char variables but I am missing out an something I guess.
It needs to be a comma seperated string just like above here : is explained.
I'm trying to make a GUI in VB which will display data coming from Arduino. The problem is I will have two Arduino sending the data. Plus I am using XBee to transmit the data from the two Arduino. But the XBee is not a problem coz it just works like a serial line. I am wondering if it's possible to read and distinguish the data from the two Arduino separately. Can anyone give me advice about this?
The problem is I will have two Arduino sending the data.
Why is this a problem? If you have two Arduinos connected to the PC, they are on different serial ports, so you need two instances of the SerialPort class - one for each port. Name the instances Fred and Sally, and you won't have any trouble keeping track of which data came from which Arduino.
The XBee is also connected to a serial port, so a third instance of the SerialPort class is required. Name it Fjrgoldowep, to keep is separate from Fred and Sally.
The XBee is the only one connected to the computer through one port, a USB-serial port. The XBee will receive the data from the two Arduino.,so it will be receiving two different data. Anyway, I thought of a way to distinguish where the data is coming from., that is to put an ID string along with the data being sent by the Arduino.
It will. Keep in mind, though, that serial data transmission is slow and asynchronous. Keeping packets as small as possible is necessary. So, instead of "mote1", "1" would be better. Also, adding start and end-of-packet markers will make identification of a packet, and parsing of the packet, easier - "<1,xxx>".
It will. Keep in mind, though, that serial data transmission is slow and asynchronous. Keeping packets as small as possible is necessary. So, instead of "mote1", "1" would be better. Also, adding start and end-of-packet markers will make identification of a packet, and parsing of the packet, easier - "<1,xxx>".
Thanks I'll take your advice. so that's the use of the { } I saw on someone else's code.