Skip to Content
Learning Robotics using Python - Second Edition
book

Learning Robotics using Python - Second Edition

by Lentin Joseph
June 2018
Beginner to intermediate
280 pages
6h 58m
English
Packt Publishing
Content preview from Learning Robotics using Python - Second Edition

Motor interfacing code

The following code in Energia can be used to test the two motors in the differential drive configuration. This code can move the robot forward for 5 seconds and backward for 5 seconds. Then, it moves the robot to the left for 5 seconds and right for 5 seconds. After each movement, the robot will stop for 1 second.

At the start of the code, we define pins for INA, INB, and PWM of the two motors, as follows:

///Left Motor  Pins 
#define INA_1 12 
#define INB_1 13 
#define PWM_1 PC_6 
 
///Right Motor Pins 
#define INA_2 5 
#define INB_2 6 
#define PWM_2 PC_5 

The pinout for Launchpad is given at: http://energia.nu/pin-maps/guide_tm4c123launchpad/

The following code shows the five functions to move the robot forward, backward, left, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Robotics using Python

Learning Robotics using Python

Lentin Joseph
Python Robotics Projects

Python Robotics Projects

Prof. Diwakar Vaish

Publisher Resources

ISBN: 9781788623315Supplemental Content