Fix #3: Update min and max to sensible defaults rileyjshaw/Servo

R/C servos have a standard pulse width range of 1000 to 2000µs1, with the zero point between the two at 1500µs. Currently, Arduino's Servo library sets:

This causes a lot of confusion2, especially since [the docs say write(90) should correspond to the mid-point] (https://www.arduino.cc/en/Reference/ServoWrite); in actuality, it results in a call to writeMicroseconds(1472)3.

This change adjusts the defaults to align with R/C standards. Specifically,

  • write(0) now corresponds to the standard min pulse width of 1000µs.
  • write(90) now corresponds to the standard zero point pulse width, and aligns with the library's DEFAULT_PULSE_WIDTH variable.
  • write(180) now corresponds to the standard max pulse width of 2000µs.

Tested on an Arduino Uno with a Tower Pro Micro Servo SG90, and a Parallax Feedback 360° High-Speed Servo.


1: For example, http://www.ee.ic.ac.uk/pcheung/teaching/DE1_EE/stores/sg90_datasheet.pdf

2: For instance:

I also see a lot of posts on https://forum.arduino.cc about this.

3: There is actually no way to set a standard servo to the zero-point using write(angle); the closest you can get is write(92), for a pulse of 1504µs.