Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Beaglebone Robotics

You're reading from   Mastering Beaglebone Robotics Master the power of the BeagleBone Black to maximize your robot-building skills and create awesome projects

Arrow left icon
Product type Paperback
Published in Dec 2014
Publisher
ISBN-13 9781783988907
Length 234 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Richard Grimmett Richard Grimmett
Author Profile Icon Richard Grimmett
Richard Grimmett
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Preparing the BeagleBone Black FREE CHAPTER 2. Building a Basic Tracked Vehicle 3. Adding Sensors to Your Tracked Vehicle 4. Vision and Image Processing 5. Building a Robot that Can Walk 6. A Robot that Can Sail 7. Using GPS for Navigation 8. Measuring Wind Speed – Integrating Analog Sensors 9. An Underwater Remotely Operated Vehicle 10. A Quadcopter 11. An Autonomous Quadcopter Index

Program to control DC motors using the BeagleBone Black


Now that you've connected your motor, here is a simple Python program to control one of the motors:

Let's look at the details. Here are the individual command statements:

  • #!/usr/bin/python: As noted earlier, this command sets up the program to be executed without invoking Python

  • import Adafruit_BBIO.PWM as PWM: This library is used to communicate with the GPIO pins

  • motor1 = "P8_13": This sets the motor to PWM control P8_13—the 13th pin on the 8th connector

  • duty_stop = 9: This sets the duty cycle of the PWM that is needed to stop the motor

  • duty_forward = 12 # 12 max: This sets the duty cycle of the PWM signal on the control pin that is needed to make the motor go in the forward direction at the maximum speed

  • duty_back = 6 # 6 min: This sets the duty cycle of the PWM signal on the control pin that is needed to make the motor go in the backward direction at the maximum speed

  • PWM.start(motor1, duty_stop, 60.0): This sets the PWM signal...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image