#include <Servo.h>
#include "HX711.h"
#define Trig 8
#define Echo 9
#define Pwmmotor 11
HX711 scale;
Servo myservo1;
Servo myservo2;
int pos = 0;
float berat;
void setup() {
Serial.begin (115200);
pinMode(Pwmmotor,OUTPUT);
myservo1.attach(3);
myservo1.write(90);
myservo2.attach(5);
myservo2.write(0);
scale.begin(A1, A0);
scale.set_scale(419); //Valor lido / Peso medido
scale.tare();
}
void loop() {
//load cell
Serial.print("berat:");
Serial.println(scale.get_units(), 1);
float berat = scale.get_units();
if (berat >= 15){
myservo1.write(0);
delay(2000);
myservo2.write(90);
analogWrite(Pwmmotor, 63);
delay(10000);
myservo2.write(0);
analogWrite(Pwmmotor, 0);
}
}