DETEKSI TELUR BAGUS / JELEK ARDUINO SENSOR LDR & AMPLI HX711 - LOADCELL
Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat mendeteksi telur bagus atau jelek dengan menggunakan sensor LDR dan loadcell. jadi jika cahaya bisa tembus ke telur maka telur dikatakan bagus namun jika tidak maka telur dikatakan buruk. untuk lebih jelasnya berikut adalah koding dan komponennya.
a. Komponen
b. Program Arduino IDE
#include <Wire.h>
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include "HX711.h"
Servo myservo1;
Servo myservo2;
Servo myservo3;
//myservo1.write(80); tutup
//myservo1.write(150); buka
//myservo2.write(40); buka
//myservo2.write(80); tutup
//myservo1.write(80); lepas
//myservo1.write(180); dorong telur
// HX711.DOUT - pin #3
// HX711.PD_SCK - pin #2
HX711 scale(3, 2);
long duration, distance;
float tera = 0;
int berat;
float fix;
int x;
int dataadc;
int nilai;
void setup() {
Serial.begin(9600);
lcd.begin();
lcd.clear();
lcd.noCursor();
myservo1.attach(9);
myservo2.attach(10);
myservo3.attach(11);
myservo1.write(80);
myservo2.write(80);
myservo3.write(80);
scale.set_scale(2280.f); // this value is obtained by calibrating the scale with known weights; see the README for details
scale.tare(); // reset the scale to 0
lcd.setCursor (0,0);
lcd.print ("LOADING... ");
delay(5000);
lcd.clear();
}
void loop() {
dataadc = analogRead(A0);
berat = scale.get_units(10) * 1;
//fix = (berat - 0.4233)/0.1586;
if(berat < 0){
berat = berat * -1;
}
lcd.setCursor(0,0);
lcd.print("Berat= ");
lcd.print(berat);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("ADC= ");
lcd.print(dataadc);
lcd.print(" ");
scale.power_down();
delay(200);
scale.power_up();
if((berat > 5)&&(dataadc < 850)){
nilai = 1;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("TELUR BAGUS ");
myservo1.write(80);
myservo2.write(80);
myservo3.write(80);
myservo3.write(180);
Serial.print(nilai);
delay(3000);
lcd.clear();
myservo1.write(80);
myservo3.write(80);
}
if((berat > 5)&&(dataadc > 850)){
nilai = 2;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("TELUR JELEK ");
myservo1.write(150);
myservo2.write(80);
myservo3.write(80);
myservo3.write(180);
Serial.print(nilai);
delay(3000);
myservo1.write(80);
myservo3.write(80);
lcd.clear();
}
if((berat > 0)&&(berat < 5)&&(dataadc < 850)){
nilai = 3;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" TDK STANDAR ");
myservo1.write(80);
myservo2.write(40);
myservo3.write(80);
myservo3.write(180);
Serial.print(nilai);
delay(3000);
myservo2.write(80);
myservo3.write(80);
lcd.clear();
}
}
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include "HX711.h"
Servo myservo1;
Servo myservo2;
Servo myservo3;
//myservo1.write(80); tutup
//myservo1.write(150); buka
//myservo2.write(40); buka
//myservo2.write(80); tutup
//myservo1.write(80); lepas
//myservo1.write(180); dorong telur
// HX711.DOUT - pin #3
// HX711.PD_SCK - pin #2
HX711 scale(3, 2);
long duration, distance;
float tera = 0;
int berat;
float fix;
int x;
int dataadc;
int nilai;
void setup() {
Serial.begin(9600);
lcd.begin();
lcd.clear();
lcd.noCursor();
myservo1.attach(9);
myservo2.attach(10);
myservo3.attach(11);
myservo1.write(80);
myservo2.write(80);
myservo3.write(80);
scale.set_scale(2280.f); // this value is obtained by calibrating the scale with known weights; see the README for details
scale.tare(); // reset the scale to 0
lcd.setCursor (0,0);
lcd.print ("LOADING... ");
delay(5000);
lcd.clear();
}
void loop() {
dataadc = analogRead(A0);
berat = scale.get_units(10) * 1;
//fix = (berat - 0.4233)/0.1586;
if(berat < 0){
berat = berat * -1;
}
lcd.setCursor(0,0);
lcd.print("Berat= ");
lcd.print(berat);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("ADC= ");
lcd.print(dataadc);
lcd.print(" ");
scale.power_down();
delay(200);
scale.power_up();
if((berat > 5)&&(dataadc < 850)){
nilai = 1;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("TELUR BAGUS ");
myservo1.write(80);
myservo2.write(80);
myservo3.write(80);
myservo3.write(180);
Serial.print(nilai);
delay(3000);
lcd.clear();
myservo1.write(80);
myservo3.write(80);
}
if((berat > 5)&&(dataadc > 850)){
nilai = 2;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("TELUR JELEK ");
myservo1.write(150);
myservo2.write(80);
myservo3.write(80);
myservo3.write(180);
Serial.print(nilai);
delay(3000);
myservo1.write(80);
myservo3.write(80);
lcd.clear();
}
if((berat > 0)&&(berat < 5)&&(dataadc < 850)){
nilai = 3;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" TDK STANDAR ");
myservo1.write(80);
myservo2.write(40);
myservo3.write(80);
myservo3.write(180);
Serial.print(nilai);
delay(3000);
myservo2.write(80);
myservo3.write(80);
lcd.clear();
}
}
c. VIDEO HASILNYA