the code is this
int QS = A2; //coil
int failsafe; //failsafe
int pot; //for mapping function
int clutch ; //for mapping function
#include <HX711_ADC.h>
//HX711 constructor (dout pin, sck pin)
HX711_ADC LoadCell(4, 5);
long t;
void setup() {
pinMode (QS, OUTPUT);
pinMode (failsafe, INPUT);
pinMode (pot, INPUT);
pinMode (clutch, INPUT);
Serial.begin(9600);
Serial.println("Wait...");
LoadCell.begin();
long stabilisingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilising time
LoadCell.start(stabilisingtime);
LoadCell.setCalFactor(696.0); // user set calibration factor (float)
Serial.println("Startup + tare is complete");
void loop() {
//update() should be called at least as often as HX711 sample rate; >10Hz@10SPS, >80Hz@80SPS
//longer delay in scetch will reduce effective sample rate (be carefull with delay() in loop)
LoadCell.update();
//get smoothed value from data set + current calibration factor
if (millis() > t + 250) {
float i = LoadCell.getData();
Serial.print("Load_cell output val: ");
Serial.println(i);
t = millis();
}
//receive from serial terminal
if (Serial.available() > 0) {
float i;
char inByte = Serial.read();
if (inByte == 't') LoadCell.tareNoDelay();
}
//check if last tare operation is complete
if (LoadCell.getTareStatus() == true) {
Serial.println("Tare complete");
}
if (clutch > 65 and failsafe < 95 and i > 225 and pot >= 0 and pot <= 25 )
digitalWrite (QS, LOW),
delay (90),
digitalWrite (QS, HIGH),
delay (60);