How to power L298N and Uno for 4 6V-DC motors and a SG90

Hello all,

Currently i am working on a school project so it is kinda urgent any help would be great.

So I am trying to make a 4WD vehicle with a HC-SR04 on top of servo. It will transfer data via a HC-05 and visualize it using Processing app.

My problem is I tried powering it this way;

Connecting 12+v and GND pins of L298N to a 9V batter(external supply) and Motor Shield GND to L298N’s GND pin. So basically I am powering L298N other than UNO that I am powering through computer right now. When use this kind of wiring there comes a weird noise out of 6V DC motors and they do not work but i know they are not broke since I checked them one by one with another 9V supply.

I attached the code i am using for stable sensored version.

4wd_stablesensor.ino (3.06 KB)

Did you check the voltage drop across the L298?

Is your 9v supply a smoke detector battery? If so, you will be horribly disappointed in how they work with motors.
They are decent at providing almost zero current for a long time. That is why they can power your smoke detector for 6 months at a time.
But they are terrible at providing enough current to run a motor. When you attempt to pull enough current to run a motor, the voltage drops. Add that to the voltage drop that your L298N has, and you probably cannot even get the motors to turn.

Edit: Much better to use a number of AA batteries or any other battery designed to deliver more current.