Go Down

Topic: Sending String from Arduino Uno to Vb.net Using Firmata (Read 2514 times) previous topic - next topic

daffigusti

Hi every one...
I would like to send string from Uno to Vb.net .

EchoString.pde
Code: [Select]

/* This sketch accepts strings and raw sysex messages and echos them back.
*
* This example code is in the public domain.
*/
#include <Firmata.h>

byte analogPin;

void stringCallback(char *myString)
{
   Firmata.sendString(myString);
}


void sysexCallback(byte command, byte argc, byte*argv)
{
   Serial.print(START_SYSEX, BYTE);
   Serial.print(command, BYTE);
   for(byte i=0; i<argc; i++) {
       Serial.print(argv[i], BYTE);
   }
   Serial.print(END_SYSEX, BYTE);
}

void setup()
{
   Firmata.setFirmwareVersion(0, 1);
   Firmata.attach(STRING_DATA, stringCallback);
   Firmata.attach(START_SYSEX, sysexCallback);
   Firmata.begin(9600);
}

void loop()
{
   while(Firmata.available()) {
       Firmata.processInput();
   }
}






And in Vb.net

Code: [Select]

Public Class Form1
Private Sub SimpleButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton1.Click
       FirmataVB1.Connect("COM14", 9600)
       FirmataVB1.QueryVersion()
       MsgBox(FirmataVB1.SerialPort1.ReadLine)
           MemoEdit1.Text = (FirmataVB1.SerialPort1.ReadLine).ToString
       MsgBox("COnnect")
   End Sub
End Class


When i try to connect...vb.net return nothing, only waiting for the responding until error occurs.

Anyone knows how to solve the problem?
thanks.

Gadget999


PaulS

There are some issues with COM ports 10 and above, with some software.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1192119372
show how to define the name of a port 10 or above. Perhaps this will make a difference.

mxm2

For those who have problems with Firmata's sysex and want to acess sysex comands easily:

Try http://connect.mind-craft.net/arduino-firmata-vb-class - change "storedInputData" variable to public and use it, e.g.:

Code: [Select]
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        arduino1.StartSysex()
        arduino1.mycommand1(20, 1)
        arduino1.EndSysex()
        Thread.Sleep(100) 'Delay less than a second
        arduino1.processInput()
        TextBox1.Text = arduino1.storedInputData(1)
End Sub


use https://github.com/jgautier/arduino-1/blob/master/examples/EchoString/EchoString.ino
and read http://firmata.org/wiki/Protocol to add your own sysex command to Arduino.vb

Go Up