arduino-libraries / Servo

Servo Library for Arduino
http://arduino.cc/
GNU Lesser General Public License v2.1
245 stars 255 forks source link

Incorrect servo read values for Nano 33 BLE Sense with MBED 1.1.6 #65

Open arpita-agrawal opened 3 years ago

arpita-agrawal commented 3 years ago

The read method of Servo returns incorrect values. If position 0 is written the read value is -1 and for 180 the returned value is ~ 177- 178.

The issue is not seen with SAM, SAMD, or AVR.

Please use the below sketch for reproducing the issue:

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  Serial.begin(9600);
}

void loop() {
  myservo.write(0);
  int currPos = myservo.read();
  Serial.println(currPos);
  delay(150);
  myservo.write(180);
  currPos = myservo.read();
  Serial.println(currPos);
  delay(150);
}