Raspberry Pi Motor Controller


An AVR, typically an ATMega168P, is controlled from the Pi via the 3.3V UART, and provides the PWM signals to the Motor Driver.


  • Controlled via the UART on the Pi GPIO Header.
  • Up to 2A bi-directional current per channel at up to 46V. (Limited by L298N)
  • Only the Motor Supply Voltage is required in addition to Voltages from the Pi GPIO Header
  • Motor Driver Channels are switched off when speed value is set to β€˜000’

Raspberry Pi Motor Controller


The Motor Controller initialises to β€˜0’ speed on both channels.

A fixed-length 10 character array is then used to instruct the controller.


  • xxx – Speed from β€˜000’ to β€˜255’
  • X – Direction, β€˜F’ or β€˜B’

The controller will then repeat back the character array, reconstructed from the internal parsed values. Any corruption or undesired effects should therefore be visible.

This should be sent at 9600 baud. Case is important, no null terminator should be used.

Note: No error-handling is currently used, any other input will cause undefined behaviour and may require an AVR reset to recover the state.

Raspberry Pi Motor Controller Schematic


The code is written using the Arduino libraries, and so should be compiled with the Arduino IDE.

To program the AVR, an ICSP should be used. This will work in-circuit as long although no power should be applied to the rest of the circuit.


Foir more detail: Raspberry Pi Motor Controller

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top