I have a simple project that utilizes ultrasonic sensor and LCD. It works great when powering the board (UNO) through USB but US sensor stops registering correct distance (and the the whole program freezes) when powering with 9v through VIN. I am using two new 9v in parallel and did multiple tests to confirm that that switching from USB to the internal power regulator (VIN) is what causes issues.
Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE
I am guessing that they are type PP3 batteries and if so they simply cannot provide enough current at the required voltage as they are intended for use in low current applications such as smoke detectors
Have you measured the battery voltage whilst they are powering your project ?
Put those batteries in smoke detectors and get a power supply or use several AA batteries in series. What you are stating your problem is extremely consistent with 9V batteries.
If all you have is 9V for a supply, use a step down converter (switchmode), to produce 5V and apply that to the 5V pin of the Uno. But not one of those 9V batteries, as mentioned.
Be inquisitive! Take one of your batteries apart. You will discover several tiny individual cells that are connected together in series to produce your 9+ volts. We call them batteries because the cells are in battery, meaning connected together, end to end.
I did the same to get the connector off the top for use to connect a 9 volt battery to a new project. No need to buy ready-made connectors. Now I have a big bag of them left over form my old company. One customer used the plastic boxes that came with the wired connector, but did not use connector. Never throw away, because.
Power (Wattage) is calculated as Voltage X Current. A 1.5V battery of the same size and same chemistry could provide the same power/energy which means 6 times the current or 6 times the mA-hours.
Except actually, there is some wasted space with 6 cells in the rectangular battery so a 1.5V battery could hold a little more energy.