I'm trying to use pin 10 to receive my serial data into the Ardunio. Then only send lines that contain "Bob" in them to excel using PLX-DAQ. So anytime pin 10 on the Arduino sees serial data, process the data and look for "Bob", then send the entire line containing "Bob'" to excel and when if a new line of data containing "Bob" comes in, update to the next row in excel. Here's what I have but not working.... I appreciate any suggestions...thank you in advance.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10); //rx on pin 10
char pattern[] = "Bob";
char row = 0;
void setup() {
Serial.begin(38400);
//Serial.print(F("Looking for '"));
//Serial.print(pattern);
//Serial.println(F("'"));
mySerial.begin(38400); // the bigger number the better
//pinMode(rxPin, INPUT)
Serial.println("CLEARDATA"); //clears up any data left from previous projects
Serial.println("LABEL,Acolumn,"); //always write LABEL, so excel knows the next things will be the names of the columns (instead of Acolumn you could write Time for instance)
}
void loop() {
byte inChar;
bool doCheck = false;
const byte lineBufferSize = 65;
static char sCBuffer[lineBufferSize];
static byte buffIndex = 0;
while (mySerial.available() > 0) {
inChar = mySerial.read();
if (inChar == 10) {
continue;
} else if (inChar == 13) {
doCheck = buffIndex;
} else {
if ((buffIndex == 0) && isWhitespace(inChar)) {
continue;
}
sCBuffer[buffIndex++] = inChar;{
doCheck = (buffIndex == (lineBufferSize - 1));
}
if (doCheck) {
sCBuffer[buffIndex] = 0;
if (strstr(sCBuffer, pattern))
Serial.print("DATA,sCBuffer");{
buffIndex = 0;
Serial.print("DATA,sCBuffer,"); //writes the time in the first column A and the time since the measurements started in column B
row++;
row=0;
Serial.println("ROW,SET,2");
//Serial.println(...); //be sure to add println to the last command so it knows to go into the next row on the second run
delay(100); //add a delay
}
}
}
}
}