Electronic – arduino – How to the Arduino Uno support up to 12 servos if it only has 6 digital PWM pins


According to this:

The Servo library supports up to 12 motors on most Arduino boards and
48 on the Arduino Mega. On boards other than the Mega, use of the
library disables analogWrite() (PWM) functionality on pins 9 and 10,
whether or not there is a Servo on those pins. On the Mega, up to 12
servos can be used without interfering with PWM functionality; use of
12 to 23 motors will disable PWM on pins 11 and 12.

However, according to this:

Digital I/O Pins 14 (of which 6 provide PWM output)

So how can the Uno control more than 6 servos if it only has 6 digital I/O pins that can provide PWM output?

Best Answer

The Servo library doesn't use PWM. When you call write() it computes a pulse width in microseconds and stores it in a global array. Then there is a single timer that regularly triggers an interrupt which changes the output signals according to each channel's desired pulse width.

You can find the source code below : Github link