Table Of ContentMake: Lego and
Arduino Projects
John Baichtal, Matthew Beckler & Adam Wolf
Sebastopol
Make: Lego and Arduino Projects
by John Baichtal, Matthew Beckler & Adam Wolf
Copyright © 2013 John Baichtal, Matthew Beckler, and Adam Wolf. All rights reserved.
Printed in Canada.
Published by Maker Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
Maker Media books may be purchased for educational, business, or sales promotional use. Online editions are also avail-
able for most titles (my.safaribooksonline.com). For more information, contact our corporate/institutional sales department:
800-998-9938 or corporate@oreilly.com.
Editors: Dale Dougherty and Brian Jepson Cover Designers: Mark Paglietti and Randy Comer
Development Editor: Brian Jepson Interior Designer: Ron Bilodeau
Production Editor: Kristen Borg Production Services: Peter Amirault
Proofreader: nSight, Inc. Illustrators: Matthew Beckler, Rebecca Demarest
Indexer: WordCo Indexing Services Cover Photographer: Adam Wolf
December 2012: First Edition.
Revision History for the 1st Edition:
2012-11-14 First release
2013-02-22 Second release
See http://oreilly.com/catalog/errata.csp?isbn=0636920024316 for release details.
Make logo and Maker Media logos are registered trademarks of Maker Media, Inc. Many of the designations used by manu-
facturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book,
and Maker Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility
for errors or omissions, or for damages resulting from the use of the information contained herein.
ISBN: 978-1-449-32106-2
[TI]
Contents
Foreword.. .. ..... .... .... . ... ..... .. ..... .. .... vii
Preface.. ... ...... ... ... . ... . .. ..... .. ...... .. ... ix
1.. Project:.Drawbot... ..... .... ..... ... ...... .. ... 1
Parts List ..................................................................... 2
Assembly Instructions ....................................................... 6
Program the Robot .........................................................24
The Next Chapter ...........................................................29
2..Anatomy.of.Lego.Robotics...... ........ .... 31
Mindstorms .................................................................32
Expanding on the Mindstorms Set .........................................39
Programming Your Brick ....................................................45
The Next Chapter ...........................................................47
3..Arduino.Interlude.. .. ...... ....... ...... .. .... 49
History of the Arduino Project ..............................................50
What Is OSHW? .............................................................51
Anatomy of the Uno ........................................................53
The Arduino Ecosystem .....................................................56
Arduino Resources ..........................................................62
The Next Chapter ...........................................................67
iii
4..Project:.Clock........ ....... ..... ... ...... . ... 69
Parts List ....................................................................70
Assembly Instructions ......................................................74
Program the Robot .........................................................88
Setting the Clock............................................................91
The Next Chapter ...........................................................91
5..Project:.Chocolate.Milk.Maker..... ........ 93
Parts List ....................................................................94
Assembly Instructions ......................................................98
Program the Robot ....................................................... 127
The Next Chapter ......................................................... 133
6..Basic.Electronic.Theory... ....... ....... ... 135
Basic Concepts in Electricity .............................................. 135
Know Your Electronic Components ....................................... 140
Sensors 101 ............................................................... 145
Further Study ............................................................. 152
7..Gripperbot...... ......... ..... ... ..... .... .... 155
Parts List .................................................................. 157
Building Instructions ...................................................... 161
Assembling the Gripperbot’s Electronics ................................. 191
Programming the Gripperbot ............................................ 192
The Next Chapter ......................................................... 201
8..Project:.Keytar.... ........ ...... ... ...... .. . 203
Parts List .................................................................. 204
Assembly Instructions .................................................... 208
Program the Keytar ....................................................... 230
Play Some Music! ......................................................... 234
The Next Chapter ......................................................... 235
9..Project:.Lamp... ........... ... ..... ... .... ... 237
Parts List .................................................................. 238
Assembly Instructions .................................................... 243
Program the Lamp ........................................................ 275
The Next Chapter ......................................................... 281
iv Contents
10.. Advanced.Techniques... .......... ...... . 283
Wiring Up Bricktronics Equivalents ....................................... 283
Mounting PCBs to Legos .................................................. 288
Adding Molex Connectors to Lego Wires ................................. 290
All About Motors .......................................................... 291
Powering Your Robot ..................................................... 294
NXT to Arduino Communication ......................................... 298
XBee Wireless Modules ................................................... 302
Epilogue .................................................................. 304
Index......... ... ..... . ... . ... ..... .... .... .... 305
Contents v
Foreword
Remember the initial excitement of experimenting
with Lego robotics? It felt like the entire universe was
open to you! With so many robots to build to tackle
interesting challenges, perform experiments, and
make interesting algorithms, the possibilities were
endless. From modifying some bricks with LEDs, to
gluing assemblies together to make your robot better,
robot building with Legos is an exciting experience.
One of my personal favorite experiments with Lego
robotics was conducting an experiment to determine
if using a light sensor or touch sensor (which was
calibrated with springs using Hooke's law) would
be better for counting pills. Between the real world
applications, as well as the scientific method applied
behind it, it ended up winning two gold medals at my
high school and regional science fairs.
In order to accelerate towards more advanced
experiments in robotics, using the RCX 2.0 was not
a viable solution. The lack of ability to interface to
various sensors and actuators was a major roadblock,
so I adventured into the land of Arduino! Since then,
my mind has been opened up to even more interesting
areas of robotics.
The journey of learning about robotics is interesting
and never-ending. This book will be a huge help to
springboard you into more in-depth robotics. Not only
will you be able to make more sophisticated robots
vii
that tackle more complex challenges or perform more
elaborate experiments, but you will have a better
opportunity to discover which area of robotics you
enjoy the most, whether it's programming, electrical,
mechanical, or design and implementation.
As you embark on your new Lego robots that utilize
Arduino, it will feel like the entire universe is open
to you again, with even more galaxies to explore!
Embrace this, as you never know where your next
robotic creation may take you. Maybe it will be like
RoboBrrd, from a prototype to a kit, inspiring even
more robot builders. Be sure to share your excitement
for robots with your friends or an online community.
Remember, robots teach us about ourselves, how we
think, behave, and act.
Welcome to the awesome world of robotics! Now get
on with the learning and advance your robots to the
next step!
— Erin "RobotGrrl" Kennedy
viii Foreword