#I'm making a obstacle avoiding robot but when I upload the code, only the right wheel moves. I've eliminated a battery problem or driver and motors. Is there anything wrong with the code?`
How are the motors and servo powered ?
Are they connected directly to pins on the Arduino and which Arduino board do you have ?
Please post a schematic of the project showing all of its components, how they are connected and how they are powered. A 'photo of a hand drawn circuit is good enough
Your code from Post #1 works... so if your hardware is not working, that indicates problems in the hardware (power supply - not enough power?, wiring - not connected the right way?, connection - bad connections? hardware - mis-matched hardware?)
I already did the wiring 3 times over to check if I follow the diagram and the batteries are fully charged. I know the l298n eats up a lot of energy but 2 should be enough right?
That means you missed something... Every day, someone "checks" their wiring, and ultimately, did not. For this reason, please, show a good photograph of your wiring and hardware.
What is the battery output?
You will be determining this.
From which pins on which module do these wire originate?
I didn't change the wires related to the motor and the driver though, the only wires I changed were thr servo wires and the battery for it to be able to plug in the breadboard
Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
The diagram in Tinker is different to your images.
One thing I can advise you to do is change the jumper wires with solid core wires, or use a digital multimeter to check each and every jumper cable. I dont trust these jumper cables, they have been the source of trouble in many of my projects.
I would start simple.
Remove the servo and sonar altogether.
Take the wheels off the motors.
Disconnect the motors (bear with me).
Write a small sketch that just sets both motors forward.
Measure the GPIO voltages at the MCU pins and at the bridge inputs.
If the MCU voltages are incorrect, check the pins you are flipping high/low in the software to be the same on the MCU.
If the bridge doesn't have the correct input voltages, replace the wires.
If those bridge voltages are correct, measure the output of the bridge.
If no output, replace the bridge.
If there is voltage at the outputs, connect the left motor then the right motor.
If only one runs, disconnect both motors and re-connect the right motor then the left motor.
If the same motor doesn't run in both cases, replace the bridge. If it still doesn't work, replace the motor.
If only the first connected motor runs in both cases and the second doesn't then there's not enough power.