For weeks, I’d been thinking that my code was wrong hence I cant move more than 2 motor at the same time or it will corrupt the system….
And in the end, it wasnt my code, as I was using PCA9685 which is a servo driver which I bought online and thought that I could control 16 motors at the same time, Yes, it could and the code can work.. the problem is the power supply. NEVER HAVE A SERVO DRIVER’S MOTOR POWER SUPPLY POWERED STRAIGHT FROM THE ARDUINO!
I finally found out today that was the main reason, when the motor drains too much of the Arduino’s power, it will brownout, causing erratic behaviors in the motors which was my main problem up till now, so instead of limiting myself to code up to two motors to move at the same time, I could potentially move all 16 motors just by finding another power supply.
My Brownout will occur when I run 4 servo at the same time, so 3 servo running simultaneously is the maximum for my current power supply, There are ways which I could solve this problem.
- Using a battery which could supply 6V power at 10A or more, after my research, battery are rarely rated at 6V and 10A is just too much for a battery, even if they do, it will drain the battery out really fast unless I am using a HUGE car battery on 12V and step down the supply using a Voltage Regulator.
- Using Multiple battery at 5 V or 6V and parallel them to increase their current, since this will be the most expensive out of all option, the only way possible to get this done is to series 4xAA battery and parallel multiple group of 4xAA to create a powerbank, the downside of this will be the voltage drop overtime due to lesser power in the battery.
- Using a power adapter with the 5V or 6V at 10A, and this will probably be more feasible due to the availability of 10A power adapter in the market, or I could use a 12V 10A power adapter along with a Voltage Regulator and step down it to 6V. I think this will be relatively doable because it will have a stable supply and I do not have to worry about recharging my battery, moreover, I might be able to supply power to my Arduino at the same time too.
I will try to find suitable power adapter along with voltage regulator, if this still don’t work as well as i thought it would work, I probably can use a capacitor to increase the current rating(I am still not sure how does this work, but I’ll figure out)