To convert
#include "HX711.h"
// Wiring settings
const int DT_PIN = 5;
const int SCK_PIN = 6;
const int scale_factor = -2.85; //Scale parameter, obtained from the calibration program
HX711 scale;
void setup() {
Serial.begin(9600);
Serial.println("Initializing the scale");
scale.begin(DT_PIN, SCK_PIN);
Serial.println("Before setting up the scale:");
Serial.println(scale.get_units(5), 0); //The value before the scale parameter is set
scale.set_scale(scale_factor); // Set scale parameters
scale.tare(); //reset to zero
Serial.println("After setting up the scale:");
Serial.println(scale.get_units(5), 0); //The value after setting the scale parameter
Serial.println("Readings:"); //Do not put anything on the electronic scale before this message
}
void loop() {
Serial.println(scale.get_units(1), 3);
//scale.power_down(); // Enter sleep mode
//delay(1);
//scale.power_up(); // End sleep mode
}
This program is output into a program library, and then used with 2 buttons to control the motor. When button 1 is pressed, it will perform an extending action, and when it is released, it will stop. When button 2 is pressed, it will perform a retracting action, and when it is released, it will also stop (button It will continue to move when you press it, and it will stop when you release it). When the motor is extended, if the value output by the above program is between 31570 and 25830, it will all stop. There will be no response when the button is pressed. When it is retracted, the program If the output value is between 2922~-2818, everything will stop and there will be no response when pressing the button. I would like to ask how to write this paragraph?