#include "HX711.h"
#include <Servo.h>
Servo myservo;
HX711 scale;
#define servoPin 9
#define loadcell (A1, A0)
int angle = 0;
int thresholdHIGH = 3500;
int alarm = 4200;
void setup() {
Serial.begin(9600);
myservo.attach(servoPin);
pinMode(servoPin, OUTPUT);
pinMode(loadcell,INPUT);
Serial.println("Initializing the scale");
scale.begin(A1, A0);
pinMode( 6, OUTPUT);
}
void loop() {
Serial.println(scale.get_units()*2.380952, 1);
int force = scale.get_units();
float Grams = (force*2.380952);
if (Grams<thresholdHIGH) {
myservo.write(90);
}
else {
myservo.write(0);
}
if (Grams>alarm){
tone(8, 262, 250);
digitalWrite(6, HIGH);
}
delay(700);
}