ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Send variables from LabView to Arduino more than 1 byte

I need to modify the LIFA_base.ino to make a application, and I need to send from LabView to Arduino new commands with some variables larger than 1 byte, but is impossible because if I cant send data more than 255 (1 byte), for example, I need to send a new command (I know how I can modify the LIFA_base.ino, this is not a problem form me), and the associated data to this command is a 1000 ms delay, but is not possible to send data larger than 255... Any idea please haw can send data larger than 1 byte?.

Thanks,

Jose

0 Kudos
Message 1 of 3
(4,170 Views)

Sending information that is more than a single byte is actually quite simple.  This is actually done in several places in LIFA.  For example, see "Analog Read Pin".

0 Kudos
Message 2 of 3
(3,487 Views)

hello friend you can program the arduino to receive the characters you need, the code is simple you can improve it...

String dato;

int out1                         =10;

int out2                         =11;

bool flat1                       =LOW;

int temp1;                             

void setup()

{

  1. Serial.begin                      (9600);

pinMode                                        (out1,OUTPUT);

pinMode                                        (out2,OUTPUT);

}

void loop()

{

       dato="";

       if     (Serial.available() )

        {

              dato         =readData();

        }

        delay(3);  

        if (dato =="c1"){ proceso1(); }

              if (dato =="c2"){ proceso2(); }

        readAnalog();

}

String readData()

{

String buffer ="";

              if (Serial.available() > 0)

              {

                     int h =Serial.available();  

                     for (int i=0;i<h;i++)

                            {

                            buffer += (char)Serial.read();

                            }

              }

                     return (buffer);

}

              

int proceso1()

{

digitalWrite(out1,HIGH);

delay(10);

digitalWrite(out1,LOW);

}

int proceso2()

{

flat1 = !flat1;

digitalWrite(out2,flat1);

}

int readAnalog()

{

temp1= analogRead(0);

Serial.println(temp1);

delay (10);

}

0 Kudos
Message 3 of 3
(3,487 Views)