I downloaded the PLX-DAQ SW for Excel. I can make graphs, so sending data from an analog input to Excel is fine. I can send this data via the serial port to Excel but not get anything back. Basically, I'd like to read if one of the boxes is checked so I can evaluate this in my program to switch between weight units. But the whole if statement can not be done.
Code:
int sample = 100;
int row=0; //int USER1=0;
float Load = 0;
int metric = 0; // 0/1 eng/met units
// choose "PLX-DAQ Simple Test";
void setup() {
// initialize the serial communication:
Serial.begin(9600); // baud rate/speed
Serial.println("CLEARDATA"); // clear data in excel on reset
Serial.println("LABEL,Time,,,LOAD/Newton"); // columnnames, Time, not TIME -> is instruction
Serial.println("MSG,Set Metric for Newton - otherwise in Pound");
Serial.println("USER1,LABEL,Metric"); // user1 new label
//Serial.println("USER1,GET"); in all variants didn't work
//USER1=Serial.read(); //
}
void loop() {
// allows serial port to send data to Excel, first field always TIME, then fields of interest (val)
Serial.print("DATA,TIME,,,");
Serial.println("USER1,GET");
if (Serial.available() > 0){
//Serial.println("USER1,GET");
metric=Serial.read();
if (metric == '1')
{Serial.println("y");}
if (metric == '0')
{Serial.println("n");}
else {Serial.println("no serial");}
}
Serial.println(Load*0.005); // read the analog input on pin 0, field of interest, and
row++; // next line
// wait a bit for the analog-to-digital converter
// to stabilize after the last reading:
delay(sample); // in milliseconds
}