Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

DC Motor Interfacing with Beaglebone Black (Part 5/15)

By Ashish Vara June 29, 2021

This tutorial explains how to interface DC motor with Beaglebone black where DC motor acts as an actuator device.  Due to insufficient current, it’s not possible to drive the motor directly from BBB and hence a motor driver IC is needed. Program is written in python script with Adafruit GPIO library.

Required Tools:

  • Beaglebone Black
  • DC motor
  • Driver IC (i.e. L293D)
  • Push button
  • 1 kΩ Resistor
  • 0.1 uF capacitor
  • Breadboard
  • Female to Female connectors

Setup of Software environment

Install the latest python version in BBB as explained in tutorial How to make first python program with Beaglebone Black. Install the  Adafruit python-GPIO library named adafruit_BBIO.

Working

I have interfaced DC motor and switch with  the Beaglebone black’s GPIO pin. When the script is  executed, it enters in a continuous loop.  One press on the switch will start rotating the motor in a clockwise direction while another press will turn it off. Press ctrl+C  to stop the execution of program form SSH command terminal.

Description

Let’s first prepare the circuit connection. Take a breadboard and provide VCC and ground from BBB to breadboard line. L293D operates on at least 4.5 V  while Switch and GPIO work on 3.3 V. BBB has on chip system 5 V and 3.3 V pin header. So you can draw both supplies from Beaglebone Black. System 5 V is drawn for L293D and 3.3V is drawn for switch and GPIO.

On one side of breadboard, connect supply 3.3 V from pin number 3rd of header P9 and ground from pin number 2nd of header P8.  On the other connect supply system 5 V from pin number 8th of header P9 and make ground common with pin number 2nd of header P8.

Push button has two terminals. Any one of them connects with ground. Provide the VCC 3.3 V through 1k ohm resistor to another terminal of push button. Common end of resistor and push button, connect with pin number 30th of header P9.

L293D is motor driver IC  that allows driving the motor in both directions. DC motor drive is on high current capacity but BBB’s GPIO pin cannot generate sufficient current to drive DC motor. L293D IC overcomes this problem and it is required to interface between BBB and DC motor. L293D also protect BBB from damage due to back emf generated by DC motor.

Pin Diagram of L293D Motor Driver IC

Fig. 1: Pin Diagram of L293D Motor Driver IC

Output of BBB is connected with input of L293D. Pin number 8th and 9th of header P8 act as motor’s positive and negative terminals respectively. Take input from these pins and connect with input1 (2nd pin of L293D) and input2 (7th pin of L293D) Pin of L293D respectively. Interface the DC motor between output1 (3rd pin of L293D) and output2 (6th pin of L293D) pin of L293D.  Provide system 5 V to both VCC (16th pin of L293D) and VSS (8th pin of L293D) pin of L293D. VCC is supply for internal logic translation in L293D and VSS is power for driver 5V.

I attached 0.1 uF capacitor between output1 and output2 terminals for alignment and back emf protection purpose. Provide the supply to Beaglebone black by connecting with PC through USB cable. Now your circuit is prepared.

Prototype of DC Motor Interfacing with Beaglebone Black (BBB)

Fig. 2: Prototype of DC Motor Interfacing with Beaglebone Black (BBB) 

Open the command terminal and take an access of Beaglebone black through SSH as explained in the tutorial getting started with Beaglebone black. Create a new file using touch command with .py extension (i.e. led.py). Open the file with any text editor (i.e. nano, vim etc.) and write a code in python language.

Configuration of GPIO pin

Import the GPIO library from adafruit Beaglebone black library by calling following line in program:

import Adafruit_BBIO.GPIO as GPIO

Configuration and function of GPIO already I explained in tutorial LED interfacing with Beaglebone Black and switch interfacing with Beaglebone black.

Run the script from terminal:

Enter the following command with file name from command prompt:

            python filename.py

i.e. python dcMotor.py

You may also like:


  • What are different types of industrial robots?

  • What types of motors are used in electric vehicles?

  • What is Wireless Electric Vehicle Charging System (WEVCS)?

  • What is the role of embedded software in electric vehicles?

  • What are the components of robotic arms and industrial robots?

  • What drone parts you need to build a quadcopter?

Project Source Code

###


# DC motor blinking Tutorial 
# developed By Ashish vara
# Engineersgarage
 
import Adafruit_BBIO.GPIO as GPIO
 
from time import sleep
 
motor_p = "P8_8"
motor_n = "P8_9"
 
BUTTON = "P9_30"
 
GPIO.setup(motor_p,GPIO.OUT)
GPIO.setup(motor_n,GPIO.OUT)
GPIO.output(motor_p, GPIO.LOW)
GPIO.output(motor_n, GPIO.LOW)
 
 
GPIO.setup(BUTTON,GPIO.IN)
while True:
 
        Button_State = GPIO.input (BUTTON)
 
        if Button_State == 0:
 
                GPIO.output(motor_p, GPIO.HIGH)
                GPIO.output(motor_n, GPIO.LOW)
        else:
 
                GPIO.output(motor_p, GPIO.LOW)
                GPIO.output(motor_n, GPIO.LOW)

###

 

Circuit Diagrams

Circuit-Diagram-DC-Motor-Interfacing-Beaglebone-Black-BBB

Project Video


Filed Under: BeagleBone, Electronic Projects

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Reducing "shoot-through" in offline Full Bridge SMPS?
  • High Side current sensing
  • How to simulate power electronics converter in PSpice?
  • Voltage mode pushpull is a nonsense SMPS?
  • Layout IRN reduction in Comparator

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe