How to control servo motors

Hi,

I'm new in Arduino programming and hardware. I'm doing a project which needs to connect 3 servo motors (MGR996R) . Long story short, I am building a conveyor belt system that will sort boxes by colour. At the end of the conveyor Im using a gripper (uses 2 MGR996R servos, 1 to open/close gripper and 1 to rotate) that will place the box in different bin. The 3rd MGR996R servo will be used to activate and push the box into a 'waste' bin if its a certain colour. I have TCS230 TCS3200 Colour Recognition Detectors and Infrared Obstacle Avoidance Sensors to use as well.

My question is how do I code the servos to operate in this way? I ordered a PWM PCA9685 servo driver and tried using the Adafruit_PWMServoDriver to control the servos but I am finding it very confusing and cant get the servos to move. Should i just connect the servos directly to the Arduino and code that way? If so, would the code be simple enough.
I am using a Mega 2560 board so should have enough pins.

I would much appreciated if anyone in the forums could help me on this. Thanks

Welcome to the forum

Your topic was MOVED to its current forum category which is more appropriate than the original as it is not an Introductory Tutorial

Always show us a good schematic of your proposed circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.

In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.

Use the </> icon from the ‘reply menu’ to attach the copied sketch.


BTW
Never power a motor off your Arduino; use an external power supply, 5v works on these motors.

You will probably need a 5v (at least 3A) power supply.

Thanks your reply. Im away from my computer now but can try copy in my proposed circuit and wiring tomorrow. The power supply im using is the Hootracker 6V 2400mAh Ni-MH AA Rechargeable Battery Pack. I have tried a simple code to move one of the motors and it seems to drive it fine.
I will be using a seperate power supply to drive the conveyor belt. I have a good understanding of how to wire everything up, its just the code to run all 3 servos im having trouble with.

Show us your attempt at a sketch so we can help you with it.

And yes, a schematic is required.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.