From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
10-14-2021 03:39 PM
Please tell me what I'm doing wrong. I am just trying to send a simple string to the Arduino in this case "1,1,1" which tells the Arduino to turn on pin 13 for 5 seconds. If I send the string via Serial Monitor on the Arduino IDE it works fine, but if I send it through labview it won't perform said action I want. I apologize if this is similar to another forum post, but I've looked through what seems like thousands of posts and cannot get this to work with any of the solutions. Thank you in advance. Here is my block diagram and code:
int led = 13;
char val;
String value;
void setup() {
Serial.begin(115200);
pinMode(led,OUTPUT);
}
void loop() {
if (Serial.available()>0){
value = "";
while (Serial.available()>0){
val = (char) Serial.read();
Serial.println(val);
value += val;
Serial.println(value);
delay(10);
}
if(value == "1,1,1"){
digitalWrite(led, HIGH);
delay(5000);
digitalWrite(led, LOW);
}
else {
digitalWrite(led, LOW);
}
}
}
Solved! Go to Solution.
10-14-2021 04:55 PM
I suspect you are missing the carriage return/line feed at the end of your command. At a minimum you should terminate any strings you are sending with a Line Feed character.
10-14-2021 09:41 PM
You might want to add a delay after the VISA Write. I suspect you are closing the port before the hardware has had a chance to send all of the data.
Also, you do not need the VISA Open.
10-15-2021 08:32 AM
Hey guys, I tried both of your suggestions and still nothing. All that that happens is RX blinks once and pin 13 blinks repeatedly for a couple of seconds, waits a second and then blinks once, like it's receiving information (even though it's not the RX pin) and that's it. When I send it through the Serial monitor RX blinks once and pin 13 goes high immediately for 5 seconds and turns off as intended (Just as an aside, I have no termination character set on the Serial monitor). I just tried a different board and it's the same behavior. If anyone can try this on their end and get it to work, I would appreciate it very much. Thanks.
10-15-2021 08:37 AM
Also, another piece of information is that it exhibits the same behavior with RX blinking once and pin 13 blinking repeatedly, pausing for a second, and then blinking once more when I open the Serial Monitor on the Arduino IDE. It might be relevant to the issue.
10-15-2021 08:45 AM
That last tidbit was the problem. I added a two second delay after the serial port configuration vi and it worked as intended.