void loop() {
if ((startup) == 0) {
sevseg.setChars("-----");
}
if (stringComplete) {
digitalWrite(Led , LOW);
String lcdData;
lcdData.reserve(30);
lcdData = inputString;
lcdData.replace("N", "");
lcdData.replace("S", "");
lcdData.replace(" ", "");
weight = lcdData.toFloat();
if (digitalRead(modeSelect) == HIGH) {
sevseg.setNumberF(weight, 3);
}
else if (digitalRead(modeSelect) == LOW) {
sevseg.setNumberF(weight, 2);
}
startup = 1;
// // clear the string:
inputString = ("");
stringComplete = false;
}
sevseg.refreshDisplay(); // Must run repeatedly
}
void serialEvent() {
if (stringComplete == false) {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
if (stringComplete == false) {
if ((inChar == 'N') || (inChar == 'S')) {
serialDataState = 1;
}
if ((serialDataState == 1) && (inChar != '\r')) {
inputString += inChar;
}
else
stringComplete = true;
}
}
}
}