I am creating an Arduino project using 4 servos connected on a protoboard.
When I power the system through the USB from my PC, everything works normally.
However, when I power the Arduino using a battery 7,4 18640 connected to the DC jack, the servos start behaving erratically (“going crazy”).
I believe this is a power issue, and I am not sure how to correctly connect a 5V UBEC to power the servos and the Arduino safely.
Could someone help me understand how to properly use a 5V UBEC with Arduino and servos to avoid this problem?
High currents going through the traces on the Arduino board then powering the servos will cause problems.
Power your servos from an external supply with external wiring thereby bypassing the Arduino.
You will of course need an Arduino GND connection going to the servo supply GND.
Always show us good images of the actual wiring and show us your complete sketch.
The fact that your Arduino is working indicates you have had some good luck. Gil's Crispy Critter Rules for Processor Hardware:
Rule #1: An Arduino is NOT a Power Supply!
Rule #2: Never connect anything inductive (motors, speakers) directly to an Arduino!
Rule #3: Avoid connecting or disconnecting wires while the power is on.
Rule #4: Do not apply power to any pin unless you are certain of what you're doing.
Rule #5: Do not exceed the maximum voltage or current ratings.
Rule #6: Many Arduinos cannot power transmitters directly.
Rule #7: Before powering your project, take a break and double-check the wiring.
Rule #8: Bad soldering makes for project failure.
LaryD’s Corollaries:
Coro #1: When starting out, add a 220Ω resistor in series with both input and output pins to protect against shorts.
Coro #2: Invest in a Digital Multi-Meter (DMM) to measure voltages, currents, and resistance.
Note: Violating these rules can turn your Arduinos into crispy critters. For optimal performance, keep your wires under 25 cm (10 inches).
Additional Tips:
The L293 motor driver, though common, is inefficient as it can lose around 3V as heat when driving both legs of a motor. Consider using a motor driver with MOSFET outputs to reduce heat loss and conserve battery power.
Not all motor drivers work with each motor, they have to be compatible.
The nRF24 radios do not work very well when powered with an Arduino even if the 5V adapter is used.
Yes, it is an 18650 battery; I sent it wrong before. Regarding the battery, I am using this type, but I cut off the connector so that only the wires remain.
I believe you are correct... the current required for the servo startup and "idle hold" could make the 7,4vdc battery dip to a voltage too low for the Arduino to stay powered up.. causing erratic behavior.
The servos should be powered by an external power supply with an output the servos require, not powered by the Arduino.
If you are supplying power through the barrel jack and the servos from the 5V pin that power has to go through the 5V regulator that can only supply about 400mA after dropping 7.4V to 5V. It will over heat and shut down. Can your servos run directly from the battery's 7.4V? What is the servo's rated voltage and current?