01-31-2024 08:04 AM
Hi Friendly Smart Labview Community,
I'm Dong, a student in Thailand. I'm doing my tiny research but I got problem when I try to read value from labview to arduino. I can't get data and I don't know what wrong in my code. I hope the community can give me some solutions or advices. Thank you so much, you guys!!!
int ledPin = 8;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
String receivedString = Serial.readStringUntil('\n');
float receivedFloat = receivedString.toFloat();
int receivedValue = int(receivedFloat + 0.5);
if (receivedValue >= 5) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}
}
Solved! Go to Solution.
01-31-2024 08:26 AM - edited 01-31-2024 08:38 AM
Your main problem is that you are not sending the Line Feed.
1. Change your VISA Open to VISA Configure Serial Port. This will set up your serial port more exactly instead of trusting the defaults.
2. Change your Number To Fractional String to a Format String. This will allow you to easily append the Line Feed character.
01-31-2024 08:38 AM
Thank you so much KNIGHT OF NI !!!!!!
I already tried and it sucessed. I'll find out reference about "Format into string" to study more