arduino / ArduinoCore-arc32

GNU Lesser General Public License v2.1
328 stars 284 forks source link

Why the connection breaks when I write the servo motor? #578

Open DengkeDu opened 6 years ago

DengkeDu commented 6 years ago

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?

Karmageddonium commented 2 years ago

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