// Library
#include "HX711.h"
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
//#include <HX711_ADC.h>
// Pin
#define DOUT 3
#define CLK 4
const int lebar= 128;
const int tinggi = 64;
const int reset = 4;
//CALIBRATION LOADCELL :
#define calibration_factor 420 // BISA DIUBAH DARI NILAI KALIBRASI
float units;
float ounces;
byte mod = 0;
// 0 - PENGUKURAN
// 1 - TARA
// 2 - KALIBRASI
// Serial in arduino
HX711 scale ;
// HX711_ADC LoadCell(HX711_dout, HX711_sck);
Adafruit_SSD1306 oled(lebar,tinggi,&Wire,reset);
// declaration
// int GRAM;
float GRAM;
void setup() {
// put your setup code here, to run once:
Serial.begin ( 9600 );
Serial.println ();
Serial.print ("Load Kalibrasi");
Serial.print ("Jangan ada benda apapun diatas loadcell");//Penting
delay(1000);
oled.begin (SSD1306_SWITCHCAPVCC,0x3C);
oled.clearDisplay();
oled.setTextSize(2);
oled.setTextColor(WHITE);
// Skala
scale.begin (DOUT,CLK);
scale.set_scale(calibration_factor);
scale.tare();
}
void loop() {
// put your main code here, to run repeatedly:
scale.set_scale(calibration_factor);
GRAM = scale.get_units (2), 4; // GUNAKAN INI DAN UBAH ANGKANYA UNTUK CALIBRASI SAAT PENGAPLIKASIAN LOADCELL
Serial.print (GRAM);
//LoadCell.update();
scale.set_scale(calibration_factor);
Serial.print (" GRAM");
units = scale.get_units(), 10;
{
units = 0.00;
}
ounces = units * 0.035274;
Serial.println();
oled.setCursor (40,0);
oled.setTextSize(2);
oled.setTextColor(WHITE);
oled.println ("BERAT");
oled.setCursor (40,25);
oled.println (GRAM);
oled.setCursor (40,48 );
oled.println ("gram");
oled.display();
}