This is my circuit - I am simply trying to power an SG90 servo from the uno. When connected to my computer via USB, everything works as expected. When I replace that with a 9V battery connected via the barrel connector and a 9V-1A adaptor cord, the servo acts weirdly.
When I use a program which should make it turn 90 degrees one way, then the other and repeat, it instead rotates continually in one direction (weird since the SG90 should only be able to rotate 180 degrees). When I use a program which tells it to do a certain movement upon receiving a signal, it just kind of twitches in the direction it should move then back to 0.
I've measured some voltages. The USB gives about 4.6V out of the 5V pin. Using the barrel connector with battery gives about 3.9V out of the 5V pin. The battery itself, although it's a 9V battery and new, gives 7.3V. I thought this may be the reason but I also tried running it from the Vin pin - here I got still about 4.6V with the USB (and it still worked) and about 5.2V with the battery.
I don't think the code itself is relevant but I can post it if anyone wants. Thanks for any help.
You are using a PP3 9V battery designed to power a smoke detector with low current that cannot supply enough current to drive the servo and the Uno
To make it worse you are powering the servo directly from the Uno rather than from an external power supply. The Uno is not designed to power external devices beyond sensors and the odd LED or two
The battery I'm using is the one provided with the elegoo super starter kit. But thank you for your advice about powering it from a separate source, I hadn't realised that was something I needed to do.
I've also tried running the servo from a USB - I can confirm the USB is outputting 5.2V, yet when I run the servo from it (with the arduino still powered by the computer) it doesn't behave at all as expected. I've read that the servo has input voltage of either 4.8V or 6V - does this mean a voltage in between these levels will not work?
The only thing that would make a difference is the internal resistance of the battery - if the servo runs at low resistance and high current, it's may drain enough volts to move the servo out of the operating range
Total battery energy is typically measured in mAh, regardless of their voltage. The power in your project also means the heat generated and dissipated by the voltage regulators that makes them overheat and turn off.
Powering the Uno with 5V through the USB connector sure looks pretty good right about now. It works and it also takes advantage of the 500mA resettable fuse.
You are ignoring the internal resistance of the battery. I don't know what it is for a typical 9V battery but I do know it is significant in relation to the current drawn by your motors. The EMF from the battery might well be 9V, but the voltage at its terminals will not be while attempting to power your motors. Try measuring the voltage while your motors are powered.
mAh is a measure of charge, not power. Power is I^2 * R but I is purely a function of input voltage and resistance - v^2/r is the useful equation. If I can't get enough power for a 5V component out of a 9V battery, it's because of internal resistance.
High current does explain why the voltage regulators were failing at lower than rated voltage though so thank you for that.