Wiring of Robot car going to damage Arduino? And powering the project

Hi, so I have to build a robot car for my school project. I knew nothing about an arduino until two weeks ago, so please excuse my ignorance, if there is anything that is not clear please let me know.

Materials:
L298N Motor Driver Controller Board: https://www.amazon.com/gp/product/B07BK1QL5T/

2 3.3V to 5V Photo Interrupter Sensors: https://www.amazon.com/dp/B08977QFK5

Arduino Uno Rev3

2 DC motors

There is a 5V regulator on the L298N that outputs 5V from a terminal. My plan is to connect this terminal to the VIN pin to power the Arduino, and then use the 5V pin on the Arduino to power my two photo interrupter sensors. I was wondering if doing this with only 4 AA 1.5V batteries would be enough (the parameters of this project allow for two more batteries). And if it would be better then do I just buy a 6 AA battery holder or do I buy a 2AA holder and use it to power my Arduino and sensors?
I watched several youtube videos saying that you can damage the Arduino if you draw too much current, short the circuit, or apply too much voltage. Would the way I am planing to have my project wired damage my Arduino in any way?

This is the schematic I drew(keep in mind I literally learned how to draw one like 5 minutes ago, so its not the best in the world):

And here is the way I plan on wiring just for reference:

Thanks:)

Connect the L298 5 volt output to UNO 5 volt pin. Vin needs 7.5 to 12 volt.
Look in the datasheet how much current the L298 5 volt manages, how much current the UNO and the sensors need!

I can see no problem.

More questions:
If I connected the uno, and the L298 in parallel with the battery would I still have to worry about connecting the 5V output pin into the uno?
The L298 draws 70 mA at most with a maximum voltage input of 42 volts. Since I connected the input and enable of the L298 to the arduino, would the current being drawn from the arduino be considered in this 70mA?
I could not find a datasheet for the sensors but their description on amazon says they can take 3.3v to 5v and that they are for the Arduino. Is that enough information for me to power them in parallel with the arduino 5V supply?

Please tell us what you are going to use for the interrupter. Are you going to print them out of plastic or do you have suitable ones already in hand?

Sensors usually only require a very small current, not enough to worry about.

There are exceptions, like gas sensors which have a heating element inside them and so need quite a large current. But your photo sensors will require only a tiny current.

The Arduino itself will probably need 20~30mA.

Where did you read this? I think you misunderstood. The L298 will draw very little current for itself, a few mA. But it is powering the motors, and they will probably require hundreds of milliamps for each motor.

Buy a 4AA holder and a 2AA holder and connect them in series. That way you have a 9V source for the UNO and a 6V source for the motors.
You can then use the UNO 5V output to power the photointerrupters.

I got it from here: https://forum.arduino.cc/t/wiring-of-robot-car-going-to-damage-arduino-and-powering-the-project/1220633/6?u=cherixjk

The hundreds of milliamps for the motors won't go back to the uno right?

Like this

You posted the wrong link.

Correct, the motor driver handles those currents.

so sorry!
https://www.sparkfun.com/datasheets/Robotics/L298_H_Bridge.pdf

ok thank you so much!

You are welcome

Ah, this?


Ok, that is much higher than I expected. I guess you should include that in the way you were expecting.

This is another reason not to use these old L29x drivers!

Hi I know it has been a while, but I did try wiring it the way you said and it worked initially. But after a while, one of the motors wasn't working and I looked up on the internet "why is my DC gear motor not working?" and it said that it needed more voltage. So I kept the 6 batteries in series and connected the L298N and Arduino in parallel with the battery and for now it is working. This won't be a problem right?

Well, batteries don't last forever, how long was "after a while"?
You never mentioned anything about the motors. Can they handle 9V?

"After a while," was like probably 10-15 seconds of non-stop moving. But it would still move, just sometimes if I gave it a little push. And before I rewired, I replaced the batteries with new ones and it would still not move. The motors I am using can handle 3-12V.

Then you may need more than just AA batteries if you want to run longer.
Can you post a link to the motors you are using?

Never mind, sorry the motors are actually rated for 3-6V...https://www.digikey.com/en/products/detail/adafruit-industries-llc/3777/8687221

But when I put the in the 9V it works much better than the 6V, would it be fine if instead of using maximum speed (255 on Arduino) I used like 200 or something?

The L298 driver will drop the voltage about 2V. So with 9V battery the motor will see 7V. It just means that the motors will get a little hotter and won’t last as long but probably not a big difference than if you ran them at 6V.
If it were me I’d use the 9V and so what if they burn out after 5 years instead of 5.5 years.