my Materials:
Arduino Uno
L298N Dual motor controller
2 DC geared motor with wheels
2 pcs 9v battery
I already uploaded my code and it run good at first time.
and it like sucks the battery, because the motor run slower. then not working now when i reset.
You might get away with using a single set of batteries.
I know a lot of people suggest using separate batteries for the motors and microcontroller but I have a bunch of robots myself and I always use a single battery pack.
Here's a tutorial I made awhile back showing how to use those L298N motor controllers.
Technically, your motor supply voltage is supposed to be 2.5V higher than the logic voltage. If you're using a 5V microcontroller, your motor supply should be at least 7.5V.
Those 9V batteries belong in smoke detectors, not robots.