#include "HX711.h"
#define DOUT 3
#define CLK 2
HX711 scale;
float calibration_factor = 420; //Hasil Kalibrasi
float units;
void setup()
{
Serial.begin(9600);
scale.begin(DOUT, CLK);
scale.set_scale();
scale.tare(); //Reset the scale to 0
long zero_factor = scale.read_average(); //Get a baseline reading
Serial.print("Zero factor: "); //This can be used to rem need to tare the scale. Useful in permanent scale projects.
Serial.println(zero_factor);
}
void loop()
{
scale.set_scale(calibration_factor); //Adjust to this calibration factor
units = scale.get_units(), 1;
if (units < 0)
{
units = 0.00;
}
Serial.print("Berat: ");
Serial.print(units);
Serial.print(" Gram");
Serial.print(" Calibration_factor: ");
Serial.print(calibration_factor);
Serial.println();
delay(1000);
if(Serial.available())
{
char temp = Serial.read();
if(temp == '+' || temp == 'a')
calibration_factor += 10;
else if(temp == '-' || temp == 'z')
calibration_factor -= 10;
}
}