Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Intel Galileo Essentials

You're reading from  Intel Galileo Essentials

Product type Book
Published in Feb 2015
Publisher
ISBN-13 9781784398903
Pages 162 pages
Edition 1st Edition
Languages

Table of Contents (15) Chapters

Intel Galileo Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Getting Started with the Galileo Accessing the GPIO Pins Adding Display Functionality Controlling DC Motors Adding Sensors Remote Control Going Further with Galileo Speech Output Index

Galileo code for the DC motor shield


Now that the HW is in place, bring up the IDE, make sure that the proper port and device are selected, and enter the following code:

The code is straightforward. It consists of the following three blocks:

  1. The declaration of the six variables that connect to the proper Galileo pins:

    int pwmA = 3;
    int pwmB = 11;
    int brakeA = 9;
    int brakeB = 8;
    int directionA = 12;
    int directionB = 13;
  2. The setup() function, which sets the directionA, directionB, brakeA, and brakeB digital output pins:

    pinMode(directionA, OUTPUT);
    pinMode(brakeA, OUTPUT);
    pinMode(directionB, OUTPUT);
    pinMode(brakeB, OUTPUT);
  3. The loop() function. This is an example of how to make the wheeled robot go forward, then turn to the right. At each of these steps, you use the brake to stop the robot:

    // Move Forward
    digitalWrite(directionA, HIGH);
    digitalWrite(brakeA, LOW);
    analogWrite(pwmA, 255);
    digitalWrite(directionB, HIGH);
    digitalWrite(brakeB, LOW);
    analogWrite(pwmB, 255);
    delay(2000);
    digitalWrite...
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 $15.99/month. Cancel anytime}