I am currently working on a robotics project that requires 16 PWM outputs to control 16 servos. Is it possible to use Arduino Uno's digital pins as PWM output pins through code?
If it is not possible, what microcontrollers do you suggest to use on such a project?
-
6"The Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega."Edgar Bonet– Edgar Bonet2018年01月29日 14:32:31 +00:00Commented Jan 29, 2018 at 14:32
-
3You can get a PCA9685 servo controller card to multiplex 16 servos through I2C. e.g.: adafruit.com/product/815Dave X– Dave X2018年01月29日 14:35:31 +00:00Commented Jan 29, 2018 at 14:35
2 Answers 2
Only specific Digital Pins marked with ~PWM can generate a PWM signal. In the case of arduino Uno the pins 3,5,6,9,10,11 are all hardware PWM driven, and are marked on the Uno with a ~ or something. Others can be driven with software PWM(though I wouldn't recommend it). As the Arduino Uno uses the ATMEGA328P, the number of pins is same with other boards using same processor.
On the other hand if you want to run 16pins for PWM, its best if you use Arduino MEGA 2560 because its processor supports more than 6 Hardware pins for PWM. Also you get the advantage of a higher memory storage for your code
PWM is not used to control servos. Servos need a pulse that is 1 to 2 ms wide, with 1.5 ms wide being the center position, that occur every 20 ms (50 Hz).
A 2560 has enough timers and the library to control up to 48 servos.
-
1It is a form of PWM, though not the PWM generated by
analogWrite()
.Edgar Bonet– Edgar Bonet2018年02月08日 08:31:39 +00:00Commented Feb 8, 2018 at 8:31
Explore related questions
See similar questions with these tags.