How to control my SG90 with 74HC595

I'd like to start a new Arduino project, and the number of servos it requires is more than the number of PWM pins that my UNO board can provide. (It's sufficient if I used no sensors, but actually, some analog pins will be occupied for them.) Therefore, it comes to me that maybe it's possible to control my SG90 via an 74HC595 IC, but I failed. I know that buying an PCA9685 is much easier; however, PCA9685 is also much more expensive. So, is there a method to use my UNO to control SG90 via 74HC595 ? Or I should just buy an PCA9685 ?

What made you think that your question has anything to do with the working of this Website and Forum? I have suggested to the Moderator to move it to the Project Guidance section.

This sort of carelessness makes unnecessary work for the Moderators.

You don't need to use PWM pins for servos. Any I/O pins (including the analog pins) can be used

...R

Robin2:
What made you think that your question has anything to do with the working of this Website and Forum? I have suggested to the Moderator to move it to the Project Guidance section.

This sort of carelessness makes unnecessary work for the Moderators.

You don't need to use PWM pins for servos. Any I/O pins (including the analog pins) can be used

...R

I'm new here, and this is my first post on Arduino forum. I'm sorry for my carelessness to sort my post into Website and Forum and for the inconvenience it brings to the moderators.

As for the advices you provide, it may be feasible for my project. However, if the number of servos I need really excess the max pin number UNO offers, can I use 74HC595 to replace PCA9685 ?

the number of servos it requires is more than the number of PWM pins that my UNO board can provide.

You don't need to us a PWM enabled pin to control a servo using the Servo library. Any digital pin will do, even the A* pins used as digital pins.

The standard Servo library can be used to control up to 12 servos. How many do you want to control ?

Actually, my project only need exactly 12 servos, but some of the sensors will occupy some analog pins. Therefore, I turn to PCA9685 or 74HC595. I've tried 74HC595, but failed. Is it possible to control SG90 via 74HC595 ?

You probably could control a couple of servos using a shift register but unless someone has written a library to support it then it is going to be very complicated for you to implement.

Do you understand how a servo works, the type of signal it requires and the strict timing requirements ?

You can get servo control boards such as this Adafruit servo controller that don't use 1 pin per servo

wu_xuan_yi:
Or I should just buy an PCA9685 ?

Yes, buying one makes multi servo projects so much easier.
Power distribution is one major feature.
If cost is a factor, I have had success using knockoffs like these.

wu_xuan_yi:
Actually, my project only need exactly 12 servos, but some of the sensors will occupy some analog pins. Therefore, I turn to PCA9685 or 74HC595. I've tried 74HC595, but failed. Is it possible to control SG90 via 74HC595 ?

IMHO it would be easier to use an Arduino Mega rather than adding components to an Uno

...R

UKHeliBob:
You probably could control a couple of servos using a shift register but unless someone has written a library to support it then it is going to be very complicated for you to implement.

Do you understand how a servo works, the type of signal it requires and the strict timing requirements ?

You can get servo control boards such as this Adafruit servo controller that don't use 1 pin per servo

Thanks for your advice.

Maybe you're right, the code for 74HC595 to control servos is too complicated for my project. Besides, it will occupy too much memory.

I've written a code for 74HC595, but it didn't work. What's more, it occupied about 1/5 memory of my UNO.

I think I will just buy a PCA9685.

vinceherman:
Yes, buying one makes multi servo projects so much easier.
Power distribution is one major feature.
If cost is a factor, I have had success using knockoffs like these.

Thanks for advices. I think I'll just buy one.

Robin2:
IMHO it would be easier to use an Arduino Mega rather than adding components to an Uno

...R

Thanks, Robin2.

This may be another method to solve this problem. I'll take it into consideration, too.

wu_xuan_yi:
Thanks for advices. I think I’ll just buy one.

When I find an affordable source for a component like this, I buy more than one.
It saves me having to wait for delivery on another one when I let the magic smoke out, or simply want one for my next project.

vinceherman:
When I find an affordable source for a component like this, I buy more than one.
It saves me having to wait for delivery on another one when I let the magic smoke out, or simply want one for my next project.

That's very good advice.

And many of these things are so cheap that it is just not worth the trouble of sending them back for a refund if one of them is faulty.

...R

vinceherman:
When I find an affordable source for a component like this, I buy more than one.
It saves me having to wait for delivery on another one when I let the magic smoke out, or simply want one for my next project.

Robin2:
That's very good advice.

And many of these things are so cheap that it is just not worth the trouble of sending them back for a refund if one of them is faulty.

...R

Robin2:
That's very good advice.

And many of these things are so cheap that it is just not worth the trouble of sending them back for a refund if one of them is faulty.

...R

That's really a good opinion that has renewed my perspective on purchasing components.

Thanks.

UKHeliBob:
You can get servo control boards such as this Adafruit servo controller that don't use 1 pin per servo

Which of course, is exactly the same servo/ PWM controller board as all the cheap ones also using the PCA9685. :grinning:

The PCA9685 is undeniably the only sensible way to do it - either servo control or multi-channel PWM dimming/ motor control. It is designed for the job, doing it all in hardware :roll_eyes: And it is quite cheap enough, much cheaper than an Arduino Mega 2560 even if that were practical!