I am trying to control a 3-6 volt motor with a raspberry pi and h-bridge. I have a separate power source for my pi and my motors.

I have tried a 6v, 9v, and 12v power source. However, the motor buzzes but will not turn. (The motors turn when power is directly applied).

I am using the code supplied in this link: https://projects.raspberrypi.org/en/projects/physical-computing/16

Is it possible the H-bridge is fried, or is the voltage drop that great? Any suggestion would be great. Also if there is a better way to directly control the motors I am all ears.

Pi and Motor setup

  • 2
    I can't make out the connections between the Pi and the motor driver board. Could you edit your question and clarify which wires are connected from the Pi to which points on the motor driver board? If I had to guess I'd say you have not connected a Pi ground to the motor driver board ground.
    – joan
    Aug 24, 2018 at 17:42
  • please post the actual code that you used .... do not post a link to a website that has a bunch of code .......... add the code to your question ...... do not put it into a comment
    – jsotola
    Aug 24, 2018 at 18:36
  • @joan it looks to me like there's a black/white zipcord going from controller to GPIO, but we can't see which ping. So, the question for Cam is what pins are those wares connected to.
    – Bob Brown
    Aug 24, 2018 at 21:26
  • 1
    @BobBrown Yes, it looks like GPIO 2/3 (pins 3/5) are connected to IN3/IN4. I'm fairly sure the underlying problem is the missing ground connection.
    – joan
    Aug 24, 2018 at 21:33
  • @joan That would explain it. (You've got better eyes than I do, too!)
    – Bob Brown
    Aug 24, 2018 at 21:45

2 Answers 2


You are missing ground / common connection between Pi and the driver board


You must connect GND pin of your raspi to ground of bridge (- of battery) Then you can use these code for test :

import RPi.GPIO as gpio

gpio.setmode(gpio.BCM) #setpinout as BCM

gpio.setup(m1in1, gpio.OUT) #m1in1 = motor 1 input 1
gpio.setup(m1in2, gpio.OUT) #m2in2 = motor 1 input 2
gpio.output(m1in1,True) #Set first pin High
gpio.output(m1in2,False) # Set second pin LOW 
# This High Low Setting means dc motor will turn forward ( Low - High means backward)

# set enable pin as output pin
m1=gpio.PWM(m1en,1000) # 1000 Hz frequency

Then you can use the command :

m1.ChangeDutyCycle(x) #where 0<x<100

That way you can learn how slow and faster your motor can turn. Some motors start turning when x = 25 , some are x = 50..

Here you can find a tutorial about PWM Raspberry Pi PWM Tutorial

*You must use enable pin for this tutorial

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.