johnny78
Full Member level 5
hi guys
im working on a project to read from electronic scale & display it on 5 7segment digits
now its all work great but there is something im looking for a solution to fix it
when i set the scale to send continous data the display works but sometimes when the scale is unstable
it sends 0 to the serial port then work again after it get stable
here is the code coded in arduino Ide
im looking for an idea to delay the display when the weight is 0
thanks
Johnny
im working on a project to read from electronic scale & display it on 5 7segment digits
now its all work great but there is something im looking for a solution to fix it
when i set the scale to send continous data the display works but sometimes when the scale is unstable
it sends 0 to the serial port then work again after it get stable
here is the code coded in arduino Ide
im looking for an idea to delay the display when the weight is 0
thanks
Johnny
Code:
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;
}
}
}
}
Last edited: