0
votes

I'm doing an Arduino Project with 2 servos, 1 buzzer and 1 RGB led...

I'm with an Arduino Uno Board, with 6 PWM pins (3, 5, 6, 9, 10, 11)...

The problem is, I need 3 pins with PWM to RGB led. But the servo library disables PWM on pins 9 and 10. From https://www.arduino.cc/reference/en/libraries/servo/ : 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.

And tone() function to use the buzzer interfere with PWM output on pins 3 and 11. From https://www.arduino.cc/reference/en/language/functions/advanced-io/tone/ : Use of the tone() function will interfere with PWM output on pins 3 and 11 (on boards other than the Mega).

So, there is only pins 5 and 6 to my RGB led...

Is there some way to use Servo without the library? Or to control the buzzer without the tone() function?

1
use an active buzzer. that will buzz with simple digitalWriteJuraj
Active buzzer is one way. Another is to realize you don't need the crappy and bloated library to control a stepper. All you need is one pin per stepper. My hexapod robots from years ago used 18 servos on a single 16-bit timer.TomServo

1 Answers

1
votes

What Juraj said. Also:

There are libraries for software PWM you could use, see SoftPWM and (an edited fork of the first one) SoftPWM.

They use only one timer, and can produce PWM signals on any pin.

I haven't tried and tested those libraries myself, but I assume they work well.

If you ever go the SAMD21 way, there's a PWM library for those Arduinos that use that microcontroller here. Had to say that, because I wrote it. Sorry.