bogde / HX711

An Arduino library to interface the Avia Semiconductor HX711 24-Bit Analog-to-Digital Converter (ADC) for Weight Scales.
MIT License
896 stars 538 forks source link

Servo twitching when using HX711 #215

Open liu1renping opened 2 years ago

liu1renping commented 2 years ago

I'm using a load cell with a servo, but when putting them together the servo twitches every few seconds.

The following codes just simply insert a servo into the HX711_basic_example. With a shorter delay(300), the servo twitches every few seconds. With longer delay, the twitches are less frequent, but still persist.

include

// HX711 circuit wiring const int LOADCELL_DOUT_PIN = 4; const int LOADCELL_SCK_PIN = 5;

HX711 scale;

include

const int servoPin = 9; Servo myServo;

void setup() { Serial.begin(57600); scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);

myServo.attach(servoPin); myServo.write(90);

Serial.println("Starting..."); }

void loop() {

while (!scale.is_ready()) { Serial.print("skip "); } Serial.println("");

long reading = scale.read(); Serial.print("HX711 reading: "); Serial.println(reading);

delay(300);

myServo.write(180); }