Using Arduino with labview

I for everyone,

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.

I use this shield and arduino uno REV.3.
http://www.cooking-hacks.com/index.php/ehealth-sensor-shield-biometric-medical-arduino-raspberry-pi.html

I have this program, but sometimes don't work very well.

Can anyone help me please?

#include <eHealth.h>
#include <eHealthDisplay.h>

String string;
char c;

void setup()
{
Serial.begin(115200);
}

void loop()
{
float temperature = eHealth.getTemperature();
if(Serial.available() > 0) string = "";

while(Serial.available() > 0)
{
c = (byte)Serial.read();
if(c == ':')
{
break;
}else
{
string += c; // string = string + c;
}
delay(1);
}

if(string == "LL")
{
Serial.print(temperature, 2);
delay(100);
}
if(string =="DL")
{
Serial.available();
}
}

Best Regards,

Read this before posting a programming question

Code tags please.

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="";
  } 
}

I zoomkat,

Thanks for help.

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).

Please help me.

Regards

I,

If i have more buttons, like ON1 an OFF1, and ON2 and OFF2, what kind of program i have to do?

Thanks for all!

But, when i put "OFF" i don't have any led to high or low.

Note that the arduino probably sees off and OFF as two different things as they use different characters. My code uses the lower case off.

I zoomkat,

Thanks for help.

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).

Please help me.

Regards

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="";
  } 
}

I,

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.

Thanks