I would like to control a 24V DC motor with a Raspberry Pi 3.

The motor is from Anaheim Automation (see the User Guide).

I already have an external 24V power supply, but I need a 5V circuit which could be controlled by a Raspberry.

What kind of electronic circuit could I make? And how could I control it by code? This is my first time programming in Python.

  • Perhaps ask on an electronics site? The Pi is pretty peripheral to the question.
    – joan
    Commented Jun 13, 2016 at 22:52
  • ok, I will try on it. ty
    – Jp75
    Commented Jun 13, 2016 at 23:02
  • If you look for 24v brushless ESC you'll find a ton of options available from the RC community. That's your best bet - most of these take a standard PWM control signal that's easy to drive from a pi or arduino.
    – T3am5hark
    Commented Oct 15, 2016 at 17:49

3 Answers 3


This motor takes 3 inputs. Direction, Run/Stop and Speed.

The Direction and Run inputs are "TTL compatible with pullup". You can drive them straight off the Pi's GPIO pins. When the pi outputs a 1 (3.3v) the pullup will convert it to TTL logic 1 (5v). When the pi outputs a zero, the motor will see a zero.

The speed input is an ANALOG voltage between 0v and 5v. Since the pi has no true analog output, I suggest this I2C DAC board: https://www.sparkfun.com/products/12918

If you need closed-loop speed feedback, you can also sense the motor speed via the PG output from the motor, using the pi's GPIO pins but you'll need a 5v to 3v converter, eg http://www.dx.com/p/2-channel-3-3v-5v-logic-level-converter-blue-384041#.WPxbtVKmOL4, since the output is not 3.3v safe.


I've driven Anaheim Automation brushless DC motors with a Raspberry Pi. The direction and run nodes can be grounded, and you need to apply a voltage to the speed node. The Pi cannot output it directly, but a HAT or breakout with an DAC will give you that capability. I used one of these although it does much more than what you need. http://pi-plates.com/daqc2r1/ That HAT board has libraries and examples to show you how to change the voltage on the DAC channels, effectively controlling the speed of the brushless DC motor.


If you want to control the speed of the motor through code, you could possibly use a motor driver to drive the motor. As far as I know the L293n motor driver is capable of controlling the speed of the motor. This tutorial might be useful.

  • 2
    The questioner has a brushless DC motor which is controlled in a completely different way to a brushed DC motor.
    – joan
    Commented Jun 14, 2016 at 11:10

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.