HAPPY BOOKSGIVING
Use code BOOKSGIVING during checkout to save 40%-55% on books and eBooks. Shop now.
Register your product to gain access to bonus material or receive a coupon.
LEGO(r) MindstormsTM has already turned hundreds of thousands of people into active robotics hobbyists. Now, there's a complete, serious guide to building LEGO Mindstorms robots. LEGO Mindstorms insider Benjamin Erwin presents 16 highly-creative, start-to-finish projects -- all explained step-by-step in the book, and presented in full color on the accompanying CD-ROM, with accompanying movies. This is far more than a "cookbook": Erwin shares unparalleled insight into the critical thinking and programming skills behind successful robotic building, stressing the connections between LEGO engineering and real-world engineering. He focuses on practical construction and programming techniques, drawing upon his extensive experience to help robot-builders avoid the pitfalls that often frustrate them. Every chapter starts with "Inspirations" that help readers understand where the ideas for the robot came from, and ends with "Further Work" suggestions for improvements or modifications. From "Tickle Me LEGO" to "Flashlight Follower," "Animal Feeder" to "Bubble Machine," each project is supplemented with even more detailed, full-color instructions, movies, and other resources on CD-ROM -- including code built with RCX, NQC, ROBOLAB, and Visual Basic.
List of Asides.
I. INTRODUCTION.
Chapter 1. Introduction.Welcome.
The Robotics Invention System Kit.
The RCX.
Other Kits.
Programming.
The CD-ROM.
What Is a Robot?
Organizing the Kit.
The Design Process.
Come up with an Idea for a Robot.
Construct the Mechanics of the Robot.
Create a Program for the Robot on a Desktop Computer.
Download the Program from the Infrared Transmitter to the Robot and Test It.
Modify the Mechanics and Program of the Robot until It Works as Planned.
Chapter 2. Getting Started.Batteries, Built-in Programs, and Firmware.
Troubleshooting.
Saving Battery Life.
Getting out of Guided Mode.
General Guidelines.
Important Web Sites.
Chapter 3. Smart Acrobot.
Acrobot.
The Constructopedia.
Building the Acrobot.
Testing Which Way the Acrobot Will Go.
Programming and Testing.
Smart Acrobot.
Inspiration.
Designing and Building.
Programming and Testing.
A Different Design.
Advanced Design Considerations.
Advanced Programming.
Further Work.
II. AT SCHOOL.
Chapter 4. THE GIRAFFE.Inspiration.
Investigation: Deciding on a Goal.
Invention: Defining the Requirements.
Coming up with Alternatives.
Designing and Building.
Implementation: Testing.
Programming.
Further Work.
Chapter 5. Walking Mechanisms.Dog.
Inspiration.
Designing and Building.
Programming and Testing.
Further Work.
Puppy.
Bug.
Designing and Building.
Further Work.
Chapter 6. FIRST LEGO League.Inspiration.
The Contest.
Bumper-Car Robot.
Line-Follower Robot.
The Competition.
Advanced Programming.
III. AT HOME.
Chapter 7. Tickle Me LEGO Robot.Inspiration.
Research: Taking It Apart.
Designing and Building.
Programming and Testing.
Further Work.
Chapter 8. Animal Feeder by John Galinato and Young Engineers from Build-it-Yourself.comIntroduction.
Inspiration.
Designing and Building.
Programming and Testing.
Further Work.
Chapter 9. CodeMaster by Paul and Julian Kramer.Inspiration.
Brainstorming.
Designing and Building.
Programming and Testing.
Further Work.
Chapter 10. Painter by Tom and Brendon Kellner.Inspiration.
Designing and Building.
Programming and Testing.
Further Work.
IV. AT WORK.
Chapter 11. Kinetic Sculptures.Bubble Machine.
Inspiration.
Designing and Building.
Programming and Testing.
Further Work.
Mathematica.
Twisting and Turning.
Inspiration.
Further Work.
Machine with Minifig.
Further Work.
Chapter 12. Keep On Moving.Inspiration.
Designing and Building.
Programming and Testing.
Further Work.
Chapter 13. Flashlight Follower.Inspiration.
Designing and Building.
Programming and Testing.
Further Work.
Advanced Programming.
Chapter 14. RCX-to-RCX Communication.IR Tag.
Inspiration.
Designing and Building.
Programming and Testing.
Further Work.
Remote Control.
Inspiration.
Designing and Building.
Programming and Testing.
Further Work. @PARTHEAD V. ADVANCED PROGRAMMING. @CHAPTER Chapter 15. Visual Basic.
Introduction.
Smart Acrobot.
Line-Follower Robot.
Spirals.
Flashlight Follower.
Further Work.
Chapter 16. ROBOLAB.Introduction.
Smart Acrobot.
Line-Follower Robot.
Spirals.
Flashlight Follower.
Further Work.
Chapter 17. NQC.Introduction.
Smart Acrobot.
Line-Follower Robot.
Spirals.
Flashlight Follower.
Further Work.
Chapter 18. Going the Distance.Inspiration.
Designing and Building.
Programming and Testing.
Advanced Programming.
Visual Basic.
ROBOLAB.
NQC.
Further Work.
Chapter 19. Elevator.Inspiration.
Designing and Building.
Programming and Testing.
Visual Basic.
NQC.
Further Work.
Chapter 20. Data Logging.Introduction.
Refrigerator.
Designing and Building.
Programming and Testing.
Doorway.
Designing and Building.
Programming and Testing.
Motor Speed.
Motor Power Level.
Further Work.
Chapter 21. Advanced Communication.Copycat.
Inspiration.
Designing and Building.
Programming and Testing.
Further Work.
Infrared Fax Machine.
Programming and Testing.
Internet Communication.
ROBOLAB.
Internet Copycat.
Further Work.
VI. APPENDIXES.
Appendix A: Further Work.Train.
Intelligent House.
Submarine.
Inspiration.
Designing and Building.
Programming and Testing.
Appendix B: Musical Notes.LEGO Curricula and Ideas.
ROBOLAB.
NQC.
Software Developer's Kit.
Appendix E: ROBOLAB Commands.For Teachers.
Inspirational/All Ages.
Elementary School/For Kids.
Middle School/Young Adults.
High School/College/Adult Hobbyists.
Psychology.
Videos.
Magazine Articles.
Papers.
Glossary.The greatest thing about LEGO is that when you are building something and have a problem, you can take some of it apart, change things, and then keep building.
--Cale Putnam, eighth grader
When the way comes to an end, then change; having changed, you pass through.
--I Ching
The LEGO Mindstorms product line is a breakthrough in the world of technological toys. With plastic gears, pulleys, beams, bricks, axles, connector pegs, and other building elements, you can create mechanical contraptions that would make Leonardo da Vinci jealous. Combine these mechanisms with motors, sensors, and a programmable LEGO brick, the Robotic Command Explorer (RCX), and your creation can run on its own, interacting with and responding to you and its environment, including other robots. There are limitless possibilities to building and programming with LEGO Mindstorms. Mobile robots, kinetic works of art, toys, robotic animals, and robots that gather data are just some of the types of projects that you will see in this book.
It's unfair to simply refer to LEGO Mindstorms as a "toy," however. The robotic devices that you can create can serve very real, practical, and serious purposes. More importantly, building and programming a robot is a rich learning experience. Your creation will never work right the first time you test it, and the process that you go through to figure out what went wrong is when the learning takes place. This book is about that process.
At the Massachusetts Institute of Technology (MIT), Gene DiSalvatore has this saying on a piece of paper in his office: "Good judgment comes from experience, and experience comes from bad judgment." Applied to LEGO robots, this statement means that building a robot that works involves building a robot that doesn't work and then figuring out what is wrong with it. The more robots you build, the better your mechanical and programming skills will become.
The LEGO Group has been designing educational products for many years. LEGO Dacta is the educational division of the LEGO Group, in the same way that LEGO Mindstorms is the new "robotic" division of the LEGO Group. In the early days, LEGO Dacta models that were connected to a serial interface box could be programmed from a computer with a language called LEGO LOGO (see Figure 0.1).
Figure 0.1 The LEGO Dacta serial interface box
LEGO LOGO was an extension of the kids' programming language LOGO, developed by Dr. Seymour Papert and others at the MIT Media Laboratory. After the serial interface box came a prototype for a programmable brick, which later became the RCX. More work has been done since the development of that first programmable brick, too. Smaller programmable bricks called crickets are less bulky than the Mindstorms RCX (see Figure 0.2).
Figure 0.2 The RCX, the brain of the LEGO Mindstorms Robotics Invention System, next to a third generation programmable brick prototype, the cricket.
But Dr. Papert and his colleagues aren't just developing hardware and software; they're developing ideas, philosophies, and theories about the nature of learning and learning environments. Dr. Papert has coined the phrase constructionism to describe his philosophy of learning. The earlier theory of constructivism states that knowledge has to be constructed--put together into coherent understandable pieces--inside of the head, and that knowledge cannot be forced into your head or passively absorbed. Constructionism adds to these ideas the notion that by constructing something of personal interest outside of your head--a robot, a work of art, or a computer program, for example--you're better equipped to construct knowledge inside of your head, using the experience that you've gained from the physical world. Those experiences give you "objects to think with" and become the tools with which you can construct knowledge. Building and programming a LEGO robot is such an experience.
For the past four years, my life has revolved around LEGO in one way or another. In 1996 I graduated from MIT and went to Tufts University to work on a project with Professor Chris Rogers to create an engineering curriculum for young students using LEGO. Dr. Rogers and his graduate students had already created a graphical programming environment for the LEGO Dacta serial interface box. Borrowing some ideas from LEGO LOGO, I made modifications to this graphical programming environment and gave it a name--"LEGO Engineer." We showed LEGO Engineer to LEGO Dacta, and they liked the concept. We were then asked to create the educational version of the software for the RCX, which is now called "ROBOLAB." Our philosophy for ROBOLAB was to create software that could be used by anyone from preschool to graduate school. ROBOLAB has easy-to-use programming interfaces that very young students are using in elementary schools, and a high-level programming environment, which includes data analysis capabilities, that is being used in middle schools, high schools, and colleges around the world.
Being involved with LEGO spread to the people around me as well. Around the same time that we were working on ROBOLAB, we were asked to recommend people who could design robots that would push the boundaries of what the RCX could do. Among other things, LEGO wanted some "cool" examples of complex mechanical creations on the cover of the upcoming Robotics Invention System box. Dr. Rogers and I recommended my housemate Anthony Fudd, who had designed a LEGO airplane complete with hot-wire airplane wing cutter. Now Anthony is employed by LEGO Mindstorms as a master builder. He is the designer of the LEGO copy machine, ATM Machine, Refrigerator Fred, Card Dealer, a robot that can clean up LEGO bricks from the floor, an elephant that squirts water, and numerous other creations.
Because of the popularity of the RCX and the growing online community surrounding it, the LEGO influence spread even further than among my housemates. When looking for beta testers for ROBOLAB, I thought of Dave Baum, a fellow MIT Phi Kappa Theta alumnus1 like Anthony Fudd and someone I had met on the LEGO User Group Network at www.lugnet.com. Dave beta-tested ROBOLAB and became one of the first users of the RCX. Although Dave loved ROBOLAB, his first love was C. After learning ROBOLAB inside and out, Dave went on to create NQC, which stands for Not Quite C. It's a C-like programming environment for the RCX.
While at Tufts, I also worked toward a master's degree in education. One of my favorite classes was "Technological Tools for Thinking and Learning" with Professor Uri Wilensky. One of the first assignments in this class was to read a little book called Mindstorms: Children, Computers, and Powerful Ideas, written in 1980 by Seymour Papert. It was a powerful experience to read about ideas that were coming into their full fruition with the preparation of the launch of the LEGO Mindstorms product line. It was inspiring to be a part of it.
In Dr. Papert's books and papers, he writes about his and others' experiences as educators working with students on various LEGO design projects. In this book, I wanted to do the same, to convey what it's like to design and build a LEGO robot. I didn't want to write a book full of instructions that show you how to build my robots. I wanted to write a book that would help you build your robots. To accomplish this, I've filled this book with descriptions of problems that were encountered when trying to design various LEGO robots, and how those problems were solved. Dr. Papert calls his stories "learning stories." The following chapters are my "learning stories" for you.
There are several reasons why I chose to write a book about LEGO robotics that would be accessible to young adults as well as full-grown ones. In my experience with LEGO robots, I have seen lots of examples of wonderful creations that have been built by adults and kids alike. By looking on the Internet or attending a robotics festival such as Mindfest at the MIT Media Lab (www.media.mit.edu/mindfest/), it's tempting to think that everyone who has used a Mindstorms kit has had success in creating wonderfully creative projects. In my experience of teaching hundreds of students and educators how to build LEGO robots, and talking to hundreds of parents and educators in person and online, however, I've seen that this isn't the case.
Students and novice adults usually encounter two problems when they make a LEGO robot. I have seen many of these same problems, frustrations, and mistakes repeated over and over again. First, the largest frustration is when the robot "falls apart." Some people blame the robot's "falling apart" on the robot, without thinking about how they can use the LEGO building elements to make their robot stronger. Parents have told me stories of kids in the home setting who have given up completely on their Mindstorms kit out of frustration because they cannot get their robots to be crash-proof, or even stay together at all. I chose, therefore, to concentrate on construction techniques throughout the book. Second, I have heard from a lot of students and their parents about the lack of inspiration for ideas about what to build with their LEGO Mindstorms kit at home. After building the obligatory bumper car, a lot of Mindstorms kit owners that I have met cannot decide what to do next, and the kit goes unused. I consider this to be a great travesty because the Mindstorms Robotics Invention System kit isn't merely a bumper car kit, but a kit that enables anything out of your wildest imagination to be built. I have tried in this book, therefore, to include example robots that span a wide range of projects from artistic kinetic sculptures to scientific laboratories. One section called "Inspiration" in most chapters is devoted to recognizing the source of the inspiration for the robot. In addition, I have included a concluding section called "Further Work" that suggests improvements or modifications to the design found in the book. My hope is that this book as a whole will serve as an inspiration for you, and that you will take these ideas even further.
1. Ironically, at least three other MIT Phi Kappa Theta alumns have also been involved with LEGO in some form or another: Dylan Glas, who worked on LEGO Engineer and the pilot year of FIRST LEGO League in my after-school Robotics Club in Weston, Massachusetts (see Chapter 6); Brian Silverman, who worked at the Media Lab in its early days; and Bill Silver, who was a parent volunteer for the pilot of FIRST LEGO League.
A
Absolute values, 246n
AC adapter, 17
Acrobot, 21-25
motor power, 238-241
See also Smart Acrobot
Add to counter command, 201
AddToDatalog command, 229
Advanced Set Up Options, 14
Algorithm, 77
Allen, Matthew, 95
Ambient light
Line-Follower robot, 81-82
Smart Acrobot, 31-33, 167-168
Angle sensors, 201, 244
bumper car, 139-140
infrared communication, 250
internet communication, 260-261
motor speed, 234-235
Animal Feeder, 95-103
Ariel, 26
Artificial life, 7n
Axles
extenders, 201, 244
vibration, 130
B
Batteries
installation, 14
IR Tag, 155
life, 16-18
troubleshooting, 15
Baum, Dave, 20, 189, 274
Beams, 48-52
height and width, 49-50
and plates, 50
BeginOfTask command, 166
Belt and pulley wheels, 140-141
Bohm, Harry, 266
BotCode, 180
Bottom-up design, 38-39
Bricks, LEGO, 4-5, 49-50
Bubble Copter Toy, 126-127
Bubble Machine, 121-134
Bug, 63-66
Build Your Own Underwater Robot, 266
Bump sensors, 89-90
Bumper car, 71-73, 140
C
Camera mechanism, 96-97, 101
Case Structure, 260
Category, element, 8-10
CD-ROM contents, 6
Check and choose command, 133, 154
Clock display, 14
Clutch gears, 141-142
Codemaster, 105-111
COM port, 14
Comments, programming, 165, 190
Compound gear train, 124-126
Conditionals, 29
Connector pegs, 49-50
Constants, 169-170
Constructopedia, 21-22
Containers, 185
Copycat, 243-250
Internet Copycat, 260-261
NQC, 248-249
ROBOLAB, 245-246
Visual Basic, 247-248
Counters, 200-203
CreateDatalog command, 229
D
Dacta Team Challenge kit, 4n
Darr, Amy, 95
Data logging, 223-241
doorway, 232-234
graphing data, 230-231
motor speed and power, 234-241
refrigerator, 224-231
DatalogNext command, 224
DCP adapter, 182n
Decoding, 245-246
define command, 197
Design process, 10-11
breaking down problems, 40
form and function, 123
top-down/bottom-up, 38-39
Designing Everyday Things, 121-122
Direct Mode commands, 259
Dog, 59-62
Doorway, 232-234
Downloading firmware, 14
Driver, 65
Dynamic values, 33
Dynamically stable mechanism, 63-64
E
Element, LEGO, 8-10
Elevator, 209-222
NQC, 219-221
Visual Basic, 216-219
Elmo. See Tickle Me LEGO robot
Encoding, 245-246
EndOfTask command, 166
Excel, Microsoft, 230-231
Expansion sets, 5
F
Fan, 124, 130-131
Fax Machine, Infrared, 250-256
Feedback, 26-27
Figure eight pattern, 117
Firmware, 14
FIRST LEGO League (FLL), 69-82
bumper car, 71-73
competition, 80-81
Line-Follower robot, 73-80
playing field, 70
Flashlight Follower, 145-150
NQC, 196-198
ROBOLAB, 187-188
Visual Basic, 176-178
For loop, 24
Fork, 186
Form, 123
Frequency, 91-93, 269
Friction, 56, 126-127
Fudd, Anthony, 8, 129
Fulcrum, 98-99
Function, 123
G
G Code, 183
Galinato, John, 95, 273
Ganson, Arthur, 136
Gears, 42-47
clutch, 141-142
compound gearing, 124-126
gear ratios, 65, 136-137
gearbox, 44, 47
gearing down, 46
gearing up, 47
idlers, 65-66
LEGO motor, 86-88, 124
pinion, 122
worm, 47, 135
Getstart.zip file, 169, 179
Getting Started, 14
Giraffe, 37-57
beams, 48-52
gears, 42-47
walking mechanism, 41-43, 52-55
Going the Distance, 199-208
NQC, 206-208
ROBOLAB, 205-206
Visual Basic, 203-205
Graphical user interface (GUI), 189
Graphing data, 230-231
Greek key pattern, 118
Guided mode, 18
H
Half-steps, 93
Hertz, Heinrich, 92
Himmelstein, Kayty, 95
Home page, personal, 8, 19
Hooks, Dan, 250
I
Idler gears, 65-66
If statements, 29, 148, 186
Inertia, 128-129, 239-240
Infinite loop, 24, 148
Infrared communication
Copycat, 243-250
Infrared Fax Machine, 250-256
IR Transmitter, 14-16, 18
Infrared Fax Machine, 250-256
NQC, 252-256
ROBOLAB, 251
Intelligent house, 265-266
Interfaces, 179-180, 189
Internet communication, 256-261
Internet CopyCat, 260-261
ROBOLAB, 257-260
Web sites, 256-257
IP address, 257, 259
IR Tag, 151-155
J
Jensen, Vickie, 266
Joystick wheel, 155-156
K
Keep On Moving robot, 139-144
Kellner, Tom and Brendon, 113
Kinetic sculptures, 121-138
Bubble Machine, 121-134
linkage system, 134-135
Machine with Minifig, 136
Twisting and Turning, 135
Kramer, Paul and Julian, 105
L
LabVIEW, 182
Laser Tag, 151
LEGO Mindstorms. See Mindstorms
LEGO Shop at Home, 272
LEGO User Group Network, 20
LEGO World Shop, 20, 271
Light sensors, 19, 105-106
ambient light, 31-33, 81-82, 167-168
Bubble Machine, 132-134
Codemaster, 106-108
Elevator, 213-214
Flashlight Follower, 146
infrared communication, 250
Keep On Moving robot, 143-144
Line-Follower robot, 74-82, 171-172, 193
Remote Control, 155-156
Smart Acrobot, 31-33, 167-168, 185
Tickle Me LEGO robot, 94
View button, 29-30
walking mechanisms, 67
See also Data logging
Line-Follower robot, 73-80
NQC, 192-194
ROBOLAB, 186
Visual Basic, 171-174
Linkage system, 134-135
Locking programs, 14
Looping, 24
Flashlight Follower, 148
Line-Follower robot, 77
repeat loops, 77, 148, 184
spirals, 175, 187, 195
while loops, 148, 192, 260
LUGNET, 20
M
Machine with Minifig, 136
Macintosh, 16, 182, 189
Martin, Fred, 130
Micromotor, 115-116
Miller, Matthew, 139
Mindstorms
products and outlets, 4-5, 271-272
Software Developer's Kit, 5n
Ultimate Accessory Set, 5
Web sites, 19-20, 41-42, 273-275
MIT Media Laboratory, 37
Modifiers, 185
Momentum, 239-240
Mond