help me to get the code, the weight is stable and has not decreased by 2 grams, and the active time is 10s to turn off the relay on the heater. This is an example of code that already calculates
if (heaterOn){
unsigned long currentTime = millis();
int currentWeight = LoadCell.getData();
if (currentTime - lastWeightUpdate >= weightCheckInterval) {
// Baca berat dari sensor timbangan
// Misalnya, LoadCell.update() dan LoadCell.get_units()
lastWeightUpdate = currentTime;
float weightReduction = initialWeight - currentWeight;
if (weightReduction < 2.0){
weightStable = false;
}
else if (weightStable){
heaterOn = false;
digitalWrite(relayPin, LOW);
Serial.println("Pemanas Mati (berat stabil)!");
weightStable = false;
}
prevWeight = currentWeight;
}
}