ArduinoCore-arc32 icon indicating copy to clipboard operation
ArduinoCore-arc32 copied to clipboard

Why the connection breaks when I write the servo motor?

Open Nettoysfkf opened this issue 8 years ago • 1 comments

I want to control the servo motor's angle through bluetooth connection on android app. It is ok for control the led on and off:

void switchCharacteristicWritten(BLEDevice central, BLECharacteristic characteristic) {
  // central wrote new value to characteristic, update LED
  Serial.print("Characteristic event, written: ");

  if (switchChar.value()) {
    Serial.println("LED on");
    digitalWrite(ledPin, HIGH);
  } else {
    Serial.println("LED off");
    digitalWrite(ledPin, LOW);
  }
}

But when I control the servo motor, the connection was break, the initial position was 90 angles:

void switchCharacteristicWritten(BLEDevice central, BLECharacteristic characteristic) {
  // central wrote new value to characteristic, update LED
  Serial.print("Characteristic event, written: ");

  if (switchChar.value()) {
    Serial.println("LED on");
    digitalWrite(ledPin, HIGH);
    myservo.write(120);
  } else {
    Serial.println("LED off");
    digitalWrite(ledPin, LOW);
    myservo.write(60);
  }
}

Why the writing for servo motor breaks the BLE connnection?

Nettoysfkf avatar Nov 20 '17 07:11 Nettoysfkf

Hi there.. 2022. Have u got a solution? Have the same problem. Thx

Karmageddonium avatar Sep 17 '22 00:09 Karmageddonium