I am trying to make a Robotic Car using 4 motors and L298n for a motor driver. The motor specifications as listed on the purchase site are given below:
- Operating Voltage: 3V~6V DC
- Gear Ratio 1:48
- No-load speed(5V): about 208RPM
- Rated Torque: 0.8 Kg.cm @ 5V
- Load current: 170mA (when it is 4.5V)
- Size: 70 x 23 x 18 mm
- Shaft Length: 10 mm
- Shaft Type: 6 mm, Double-D
(I have removed all jumpers)
and following is the code I am using the run the motors
import RPi.GPIO as gpio import time gpio.setmode(gpio.BOARD) gpio.setup(7,gpio.OUT) gpio.setup(11,gpio.OUT) gpio.setup(13,gpio.OUT) gpio.setup(15,gpio.OUT) gpio.output(7,True) gpio.output(11,True) while True: gpio.output(13,True) gpio.output(15,False) time.sleep(2) gpio.output(13,False) gpio.output(15,True) time.sleep(2) gpio.output(13,False) gpio.output(15,False) time.sleep(2)
Problem : When I run the script, The motors spins first cycle of the loop and the stops spinning.
What I tried : The motors only start spinning again for another cycle if I disconnect and reconnect the ground cable that connects Rpi ground to L298n ground. This problem doesn't occur when I am providing 12V 1A power supply(reads as 20V DC on my multimeter, I don't know why though) instead of the 4 x AA 1.5V batteries which I want to use.
Question : Is this a problem of power supply or am I doing something else wrong? I have tried multiple tutorials on the youtube but couldn't figure out the problem.
I am stuck with this for a week now. I can provide with more information, if you can specify what you want in the comments....