system
April 19, 2011, 6:49pm
1
I'm trying to establish a serial connection between my Arduino Uno and LabVIEW. I have written a LabVIEW program that sends a string of "0" or "1" over the serial connection. I want the Arduino to turn on an LED when it sees the "1" string, however the LED is not lighting up and I'm having trouble identifying the problem. Does it look like my code has been written correctly?
int serialreading = 0;
void setup()
{
Serial.begin(9600);
pinMode(3, OUTPUT);
}
void loop() {
if (Serial.available() > 0)
{
serialreading = Serial.read();
if (serialreading != '0')
digitalWrite(3, HIGH);
if (serialreading == '0')
digitalWrite(3, LOW);
}
}
system
April 19, 2011, 7:05pm
2
What exactly is your Labview sending?
system
April 19, 2011, 7:45pm
3
Here is the labview file. I believe that it is sending a string of either 0's or 1's.
ArduinoLED_Test.vi (13.6 KB)
system
April 19, 2011, 7:48pm
4
Here is the labview file.
As something we can read would be even better...
system
April 19, 2011, 7:53pm
5
I believe that it is sending a string of either 0's or 1's.
Belief may cut it in church, but here we need something a little more concrete.
Does it send a string of 0s and 1s, or a string of '0's and '1's ?
system
April 19, 2011, 8:02pm
6
I am sending a string of characters -- either zero or one.
system
April 19, 2011, 8:16pm
7
Are you sending zeros and ones or the ASCII representation of zero and one?
system
April 19, 2011, 9:05pm
8
I have modified the LabVIEW program. It now sends bytes of value 0 or 1.
system
April 20, 2011, 6:46am
9
have modified the LabVIEW program. It now sends bytes of value 0 or 1.
But your Arduino sketch above is looking for ASCII '0' (0x30).