i am trying to send data via Labview to my arduino board using serial communication.My problem is that the arduino reads only the first byte of sent data then when i change it ,it doesn't react.
For example when i start the communication i send '0' to arduino.I sees it.but while it is running i send '1' but it doesn't behave accordingly to it.
I noticed also that the board 'sees' sometime the new value after a random period of time.
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}
char data = 'F';
void loop()
{
data = Serial.read();
delay(50);
if (data == '0')
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
if (data == '1')
{
digitalWrite(13, HIGH);
delay(4000);
digitalWrite(13, LOW);
delay(4000);
}
data = '4';
}