VB.NET and Arduino

Hello

I would like to send and read data from Arduino Duemilanove.

I've established a connection via mscomm control but it's difficult: "if I send a command...let's say "P5O" arduino reads only one character.
I would like Arduino to read commands and respond to them.

I also tried FirmdataVB with limited success: I could activate a pin to light a LED but not set his value/voltage. I also could not read from analog pins. FirmdataVB looks like the way to go with the protocol, but it's not providing all the basic functions.

Any help would be appreciated

VB.NET might be hard, but that doesn't qualify as a reason for posting in the hardware section.

There are plenty of examples for how to read more than a single byte from the serial port. zoomkat and I have both posted ways to do it. A little time with the search field and button would go a long way towards finding you answers.

Note: I am NOT picking on the newbie.

sorry, meant to post in software > interfacing

I would prefer using firmdataVB as I don't have to write the protocol myself. But i'm having problems with it as described above.

will check the multy-byte sending out

I would prefer using firmdataVB as I don't have to write the protocol myself.

Defining a protocol is easy. Implementing it is not much more challenging. Getting a string of characters sent and read is the hard part, and there are plenty of examples (search for "started && ended", for example).

Parsing the string is pretty easy, too. Some ways of formatting the string are easier than others. "<8:1>" to turn on pin 8 is a bit easier to parse than "Hey, what say you turn pin eight on".

If you get stuck, make a list of the things that the VB app wants the Arduino to do, and post it here.

ok, will search for it and try.

Basically I want to control arduino with commands like you mentioned.
something like:

  • turn on pin1 with voltage/value 200: "P1_OUT_200"
  • report value on pin5: "P2_IN"
    ...

Here is the code I was referring to:

char inData[24];
byte index;
boolean started = false;
boolean ended = false;

void loop()
{
  while(Serial.available() > 0)
  {
      char aChar = Serial.read();
      if(aChar == '<')
      {
          started = true;
          index = 0;
          inData[index] = '\0';
      }
      else if(aChar == '>')
      {
          ended = true;
      }
      else if(started)
      {
          inData[index] = aChar;
          index++;
          inData[index] = ',';
      }
  }

  if(started && ended)
  {
      // Do something with the data

      // Get ready for the next time
      started = false;
      ended = false;

      index = 0;
      inData[index] = '\0';
  }
}

Basically I want to control arduino with commands like you mentioned.
something like:

  • turn on pin1 with voltage/value 200: "P1_OUT_200"
  • report value on pin5: "P2_IN"

A space between the P and the 1 (or 2) would be good. Spaces make better delimiters than underscores, in my opinion.

I'm trying to compile your code and it says: "function main: undefined reference to `setup'" ? sample code compiles ok

oh, my bad. forgot to add void setup to the code

Nice, got the protocol to work with your loop and strtok loop. Will use your suggested format: <1:2:3:4>

first part: analog od digital pins
second part: pin number
third part: input or output
fourth part: value

Just needed a push in the right direction.

Thank you