0
\$\begingroup\$

I have a system which includes a Raspberry Pi, 2 a L298N module, 12V Battery source(8x1.5V AA) and a motor (a "PMDC Spur Gear Motor/KGA25RP")

When I connect everything right and run a simple program, only thing I see is a very low buzzing sound from motor while program running. Is my battery too low to move motor?

The code :

import RPi.GPIO as GPIO
from time import sleep

GPIO.setmode(GPIO.BOARD)

Motor1A = 38
Motor1B = 40
Motor1E = 7

GPIO.setup(Motor1A,GPIO.OUT)
GPIO.setup(Motor1B,GPIO.OUT)
GPIO.setup(Motor1E,GPIO.OUT)

print "Going forwards"
GPIO.output(Motor1A,GPIO.HIGH)
GPIO.output(Motor1B,GPIO.LOW)
GPIO.output(Motor1E,GPIO.HIGH)

sleep(2)

print "Going backwards"
GPIO.output(Motor1A,GPIO.LOW)
GPIO.output(Motor1B,GPIO.HIGH)
GPIO.output(Motor1E,GPIO.HIGH)

sleep(2)

print "Now stop"
GPIO.output(Motor1E,GPIO.LOW)

GPIO.cleanup()

Photos : imgur.com/ujjtbIH,Db3ingN,gXR3vjL

I used Raspberry pi's 7(motor 2 enable),38(IN4),40(IN3)pins.

keytosmart.com/wp-content/uploads/2014/07/B_Diagram_large.png (Can't link more than 2 links.)

\$\endgroup\$
2
  • \$\begingroup\$ Comments are not for extended discussion; this conversation has been moved to chat. \$\endgroup\$
    – Dave Tweed
    Commented Mar 3, 2017 at 14:37
  • \$\begingroup\$ For a start you never turn off the move backwards, you just turn off your direction indicator. Try following the steps here: instructables.com/id/Raspberry-PI-L298N-Dual-H-Bridge-DC-Motor ....he provides you with better code. You should be able to test your motor connected directly to the battery, if that does not work then you need to fix that first. \$\endgroup\$ Commented Mar 3, 2017 at 19:10

1 Answer 1

0
\$\begingroup\$

Make sure your the ground on your RPi is tied to the ground of the driver board.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.