LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with sending data from labview to arduino

Hi guys.

my english it's not very good,sorry about that.

I programing arduino uno with this code and I sending data with labview(2011) to arduino but it does not work well.

This means when labview is running,LED on arduino is turn on and turn off and when labview became stop, LED is turn on and turn off continuously while it must remain off.

please help me.

 

 

char in=0;  
void setup() {
Serial.begin(9600);
pinMode(13 , OUTPUT);
             }


void loop() {
if (Serial.available() > 0)
    in = Serial.read();
if(in=='2'){   
    digitalWrite(13, HIGH);
        delay(100);
    digitalWrite(13, LOW);
        delay(100);               
          in=0;
           } 

0 Kudos
Message 1 of 2
(2,779 Views)

First, only put the VISA write in the while loop.  Put the configure serial port before the while loop and the VISA close after the while loop.

 

If you want the ardino code to stop when you stop your LabVIEW VI, you need to do another VISA write with a value thats your Arduino code to turn off the LED then stop looping.

0 Kudos
Message 2 of 2
(2,766 Views)