Coding dan skema aslinya saya peroleh dari link di bawah:
https://circuitdigest.com/microcontroller-projects/arduino-weight-measurement-using-load-cell
Terima kasih...
https://circuitdigest.com/microcontroller-projects/arduino-weight-measurement-using-load-cell
Terima kasih...
Baca juga link di bwh.
Timbangan led 7segment 4digit 0.56'', Arduino Nano, HX711 dan load cell 300kg.
https://wayanlukito.blogspot.co.id/2018/02/hx711-7segment-4digit-arduino-nano.html
Timbangan led 7segment 4digit 0.56'', Arduino Nano, HX711 dan load cell 300kg.
https://wayanlukito.blogspot.co.id/2018/02/hx711-7segment-4digit-arduino-nano.html
Saya menggunakan arduino uno R3 cloningan yang harganya Rp75000, modul HX711, LCD 16x2, dan load cell 300Kg.
Coding telah saya rubah dengan cara "trial and error" alias coba gagal dan coba lagi.
Coding aslinya diperuntukan untuk satuan dalam unit "gram" yang mana telah saya rubah dalam satuan unit "kilo gram = Kg".
Tentunya ini hasil yg tidaklah sesempurna yang saya harapkan namun inilah yang "terbaik" saat saya berbagai macam coding yg telah saya uji.
Tentunya ini hasil yg tidaklah sesempurna yang saya harapkan namun inilah yang "terbaik" saat saya berbagai macam coding yg telah saya uji.
-Adapun kelemahan timbangan ini sbb:
1. Tidak bisa menimbang benda yg bobotnya kurang dari 1Kg. Sebetulnya bisa saja dibuat, bisa menimbang berat benda kurang dari 1Kg namun akibatnya terjadi fliker di LCD nya.
2. Timbangan ini tidak cocok untuk jual beli.
1. Tidak bisa menimbang benda yg bobotnya kurang dari 1Kg. Sebetulnya bisa saja dibuat, bisa menimbang berat benda kurang dari 1Kg namun akibatnya terjadi fliker di LCD nya.
2. Timbangan ini tidak cocok untuk jual beli.
3. Display nya terlalu kecil.
-Kelebihannya timbangan ini bisa menimbang berat beban lebih dari 140Kg, max s/d 315Kg.
Lihat codingnya di bawah
===========
Sket pertama
===========
Sket pertama
===========
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
#define DT A0
#define SCK A1
#define sw 2
long sample=0;
float val=0;
long count=0;
unsigned long readCount(void)
{
unsigned long Count;
unsigned char i;
pinMode(DT, OUTPUT);
digitalWrite(DT,HIGH);
digitalWrite(SCK,LOW);
Count=0;
pinMode(DT, INPUT);
while(digitalRead(DT));
for (i=0;i<24;i++)
{
digitalWrite(SCK,HIGH);
Count=Count<<1;
digitalWrite(SCK,LOW);
if(digitalRead(DT))
Count++;
}
digitalWrite(SCK,HIGH);
Count=Count^0x800000;
digitalWrite(SCK,LOW);
return(Count);
}
void setup()
{
Serial.begin(9600);
pinMode(SCK, OUTPUT);
pinMode(sw, INPUT_PULLUP);
lcd.begin(16, 2);
lcd.print("BERAT");
lcd.setCursor(0,1);
lcd.print("MENGHITUNG");
delay(1000);
lcd.clear();
calibrate();
}
void loop()
{
count= readCount();
int w=(((count-sample)/val)-2*((count-sample)/val));
Serial.print("berat:");
Serial.print((int)w);
Serial.println("Kg");
lcd.setCursor(0,0);
lcd.print("BERAT");
lcd.setCursor(0,1);
lcd.print(w/100);
lcd.print(" Kg ");
if(digitalRead(sw)==0)
{
val=0;
sample=0;
w=0;
count=0;
calibrate();
}
}
void calibrate()
{
lcd.clear();
lcd.print("KALIBRASI...");
lcd.setCursor(0,1);
lcd.print("TUNGGU...");
for(int i=0;i<100;i++)
{
count=readCount();
sample+=count;
Serial.println(count);
}
sample/=100;
Serial.print("Avg:");
Serial.println(sample);
lcd.clear();
lcd.print("SIAP");
count=0;
while(count<1000)
{
count=readCount();
count=sample-count;
Serial.println(count);
}
lcd.clear();
lcd.print("TUNGGU LAGI...");
delay(2000);
for(int i=0;i<100;i++)
{
count=readCount();
val+=sample-count;
Serial.println(sample-count);
}
val=val/100.0;
val=137; // ubahlah 137 utk mendapatkan berat yg sesuai
lcd.clear();
}
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
#define DT A0
#define SCK A1
#define sw 2
long sample=0;
float val=0;
long count=0;
unsigned long readCount(void)
{
unsigned long Count;
unsigned char i;
pinMode(DT, OUTPUT);
digitalWrite(DT,HIGH);
digitalWrite(SCK,LOW);
Count=0;
pinMode(DT, INPUT);
while(digitalRead(DT));
for (i=0;i<24;i++)
{
digitalWrite(SCK,HIGH);
Count=Count<<1;
digitalWrite(SCK,LOW);
if(digitalRead(DT))
Count++;
}
digitalWrite(SCK,HIGH);
Count=Count^0x800000;
digitalWrite(SCK,LOW);
return(Count);
}
void setup()
{
Serial.begin(9600);
pinMode(SCK, OUTPUT);
pinMode(sw, INPUT_PULLUP);
lcd.begin(16, 2);
lcd.print("BERAT");
lcd.setCursor(0,1);
lcd.print("MENGHITUNG");
delay(1000);
lcd.clear();
calibrate();
}
void loop()
{
count= readCount();
int w=(((count-sample)/val)-2*((count-sample)/val));
Serial.print("berat:");
Serial.print((int)w);
Serial.println("Kg");
lcd.setCursor(0,0);
lcd.print("BERAT");
lcd.setCursor(0,1);
lcd.print(w/100);
lcd.print(" Kg ");
if(digitalRead(sw)==0)
{
val=0;
sample=0;
w=0;
count=0;
calibrate();
}
}
void calibrate()
{
lcd.clear();
lcd.print("KALIBRASI...");
lcd.setCursor(0,1);
lcd.print("TUNGGU...");
for(int i=0;i<100;i++)
{
count=readCount();
sample+=count;
Serial.println(count);
}
sample/=100;
Serial.print("Avg:");
Serial.println(sample);
lcd.clear();
lcd.print("SIAP");
count=0;
while(count<1000)
{
count=readCount();
count=sample-count;
Serial.println(count);
}
lcd.clear();
lcd.print("TUNGGU LAGI...");
delay(2000);
for(int i=0;i<100;i++)
{
count=readCount();
val+=sample-count;
Serial.println(sample-count);
}
val=val/100.0;
val=137; // ubahlah 137 utk mendapatkan berat yg sesuai
lcd.clear();
}
================
Sket kedua alternatif
================
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
#define DT A0
#define SCK A1
#define sw 2
long sample=0.0;
float val=0.0;
long count=0.0;
unsigned long readCount(void)
{
unsigned long Count;
unsigned char i;
pinMode(DT, OUTPUT);
digitalWrite(DT,HIGH);
digitalWrite(SCK,LOW);
Count=0.0;
pinMode(DT, INPUT);
while(digitalRead(DT));
for (i=0;i<24;i++)
{
digitalWrite(SCK,HIGH);
Count=Count<<1;
digitalWrite(SCK,LOW);
if(digitalRead(DT))
Count++;
}
digitalWrite(SCK,HIGH);
Count=Count^0x800000;
digitalWrite(SCK,LOW);
return(Count);
}
void setup()
{
Serial.begin(9600);
pinMode(SCK, OUTPUT);
pinMode(sw, INPUT_PULLUP);
lcd.begin(16, 2);
lcd.print("BERAT");
lcd.setCursor(0,1);
lcd.print("MENGHITUNG");
delay(1000);
lcd.clear();
calibrate();
}
void loop()
{
count= readCount();
int w=((((count-sample)/val)-2*((count-sample)/val))/10.0);
Serial.print("berat:");
Serial.print((int)w);
Serial.println(" Kg ");
lcd.setCursor(0,0);
lcd.print("BERAT");
lcd.setCursor(0,1);
lcd.print(w/10.0);
lcd.print(" Kg ");
if(digitalRead(sw)==0)
{
val=0.0;
sample=0.0;
w=0.0;
count=0.0;
calibrate();
}
}
void calibrate()
{
lcd.clear();
lcd.print("KALIBRASI...");
lcd.setCursor(0,1);
lcd.print("TUNGGU...");
for(int i=0;i<100;i++)
{
count=readCount();
sample+=count;
Serial.println(count);
}
sample/=100;
Serial.print("Avg:");
Serial.println(sample);
lcd.clear();
lcd.print("SIAP...");
count=0.0;
while(count<1000)
{
count=readCount();
count=sample-count;
Serial.println(count);
}
lcd.clear();
lcd.print("TUNGGU LAGI...");
delay(2000);
for(int i=0;i<100;i++)
{
count=readCount();
val+=sample-count;
Serial.println(sample-count);
}
val=val/100.0;
val=137; // ubahlah 137 utk mendapatkan berat yg sesuai
lcd.clear();
}
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
#define DT A0
#define SCK A1
#define sw 2
long sample=0.0;
float val=0.0;
long count=0.0;
unsigned long readCount(void)
{
unsigned long Count;
unsigned char i;
pinMode(DT, OUTPUT);
digitalWrite(DT,HIGH);
digitalWrite(SCK,LOW);
Count=0.0;
pinMode(DT, INPUT);
while(digitalRead(DT));
for (i=0;i<24;i++)
{
digitalWrite(SCK,HIGH);
Count=Count<<1;
digitalWrite(SCK,LOW);
if(digitalRead(DT))
Count++;
}
digitalWrite(SCK,HIGH);
Count=Count^0x800000;
digitalWrite(SCK,LOW);
return(Count);
}
void setup()
{
Serial.begin(9600);
pinMode(SCK, OUTPUT);
pinMode(sw, INPUT_PULLUP);
lcd.begin(16, 2);
lcd.print("BERAT");
lcd.setCursor(0,1);
lcd.print("MENGHITUNG");
delay(1000);
lcd.clear();
calibrate();
}
void loop()
{
count= readCount();
int w=((((count-sample)/val)-2*((count-sample)/val))/10.0);
Serial.print("berat:");
Serial.print((int)w);
Serial.println(" Kg ");
lcd.setCursor(0,0);
lcd.print("BERAT");
lcd.setCursor(0,1);
lcd.print(w/10.0);
lcd.print(" Kg ");
if(digitalRead(sw)==0)
{
val=0.0;
sample=0.0;
w=0.0;
count=0.0;
calibrate();
}
}
void calibrate()
{
lcd.clear();
lcd.print("KALIBRASI...");
lcd.setCursor(0,1);
lcd.print("TUNGGU...");
for(int i=0;i<100;i++)
{
count=readCount();
sample+=count;
Serial.println(count);
}
sample/=100;
Serial.print("Avg:");
Serial.println(sample);
lcd.clear();
lcd.print("SIAP...");
count=0.0;
while(count<1000)
{
count=readCount();
count=sample-count;
Serial.println(count);
}
lcd.clear();
lcd.print("TUNGGU LAGI...");
delay(2000);
for(int i=0;i<100;i++)
{
count=readCount();
val+=sample-count;
Serial.println(sample-count);
}
val=val/100.0;
val=137; // ubahlah 137 utk mendapatkan berat yg sesuai
lcd.clear();
}
Penutup
Semoga tulisan ini tidak berguna sama sekali.
Paling2 tidak ada yg membaca.
Semoga tulisan ini tidak berguna sama sekali.
Paling2 tidak ada yg membaca.