ladypi wrote: ↑Mon May 13, 2019 10:35 amhi guys
i used l298 for driving motors and everything goes right and dont have error for python code to run
but when i send command to run, motor doesnt work!
what is the problem?
i used this tutorial:
https://www.electronicshub.org/raspberr ... pberry-pi/
https://daneshjookit.com/%D9%85%DA%A9%D ... motor.html
thanks, check this photo
Code: Select all
import RPi.GPIO as GPIO from time import sleep in1 = 24 in2 = 23 en = 25 temp1=1 GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(in1,GPIO.OUT) GPIO.setup(in2,GPIO.OUT) GPIO.setup(en,GPIO.OUT) GPIO.output(in1,GPIO.LOW) GPIO.output(in2,GPIO.LOW) p=GPIO.PWM(en,1000) p.start(25) print("\n") print("The default speed & direction of motor is LOW & Forward.....") print("r-run s-stop f-forward b-backward l-low m-medium h-high e-exit") print("\n") while(1): x=raw_input() if x=='r': print("run") if(temp1==1): GPIO.output(in1,GPIO.HIGH) GPIO.output(in2,GPIO.LOW) print("forward") x='z' else: GPIO.output(in1,GPIO.LOW) GPIO.output(in2,GPIO.HIGH) print("backward") x='z' elif x=='s': print("stop") GPIO.output(in1,GPIO.LOW) GPIO.output(in2,GPIO.LOW) x='z' elif x=='f': print("forward") GPIO.output(in1,GPIO.HIGH) GPIO.output(in2,GPIO.LOW) temp1=1 x='z' elif x=='b': print("backward") GPIO.output(in1,GPIO.LOW) GPIO.output(in2,GPIO.HIGH) temp1=0 x='z' elif x=='l': print("low") p.ChangeDutyCycle(25) x='z' elif x=='m': print("medium") p.ChangeDutyCycle(50) x='z' elif x=='h': print("high") p.ChangeDutyCycle(75) x='z' elif x=='e': GPIO.cleanup() break else: print("<<< wrong data >>>") print("please enter the defined data to continue.....")
https://imgur.com/r6xJLLApcmanbob wrote: ↑Wed May 15, 2019 11:31 amSorry but that picture is to small to clearly see anything.
Try uploading a larger image to an image sharing site like imgur.com and then post a link to it here, we need to be able to see detail like this
Are you sure your motor will run from the adapter you are using ?
have you tried connecting the motor directly to the adaptor to see if the motor runs ?
thanks alot. i,ll with check it and tell you resultpcmanbob wrote: ↑Wed May 15, 2019 11:45 amWell the connections between the pi and motor drive board look ok and I guess you have power connected to motor drive board because the red LED is lit.
when you try to run the motor does that red LED go out ?
Have you tried replacing the motor with a volt meter to see if you actually have any voltage on the motor terminals ?
Have you tried testing the motor drive board by manually making connections between control pins and 5v /ground on motor driver board with out having any connection to the pi what so ever ?
So I just tested the program with an L298N and it works just fine motor running forward at low only gives 9.6V when using a 12V psu.
And that's with no motor connected so no load, so either your motor board is faulty, you have a bad connection some were, you motor will not run at the voltage supplied by your PSU or your PSU cant run both the motor and the motor driver board causing the motor driver board to shutdown.
That was my example picture to show the OP what sort of detail was required when posting pictures of wiring/gpio connections ,