I have an aplication with 2 buttons in labview. ON an OFF.
I need that when in labview i press on the arduino program sends with serial port the value of the Serial.print.
When i press OFF the program return to begining and wait for orders from labview from other sensors.
Very basic on/off code you can try with the serial monitor, and if that works, you can try it with your labview code.
// zoomkat 8-6-10 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later
int ledPin = 13;
String readString;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
Serial.println("serial on/off test 0021"); // so I can keep track
}
void loop() {
while (Serial.available()) {
delay(3);
char c = Serial.read();
readString += c;
}
if (readString.length() >0) {
Serial.println(readString);
if (readString == "on")
{
digitalWrite(ledPin, HIGH);
}
if (readString == "off")
{
digitalWrite(ledPin, LOW);
}
readString="";
}
}
But, when i put "OFF" i don't have any led to high or low.
If the ON button is pressed he print with Serial.print. When i pressed OFF he returns to begining of program and waits for a pressed button (ON or OFF).
But, when i put "OFF" i don't have any led to high or low.
If the ON button is pressed he print with Serial.print. When i pressed OFF he returns to begining of program and waits for a pressed button (ON or OFF).
But, when i put "OFF" i don't have any led to high or low.
I changed my code to look for "ON" and "OFF" (upper case) so you can try it again.
// zoomkat 8-6-10 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later
int ledPin = 13;
String readString;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
Serial.println("serial on/off test 0021"); // so I can keep track
}
void loop() {
while (Serial.available()) {
delay(3);
char c = Serial.read();
readString += c;
}
if (readString.length() >0) {
Serial.println(readString);
if (readString == "ON")
{
digitalWrite(ledPin, HIGH);
}
if (readString == "OFF")
{
digitalWrite(ledPin, LOW);
}
readString="";
}
}
My problem is not the OFF or off.
I don't have any led to high or low.
I just want, that i press a button in labview i obtain via serial port from the arduino program a value from sensor.
When i do not have pressed the button in labview the program of arduino have to wait for another press from a button in labview.