beginning_lego_mindstorms_ev_3.pdf

(24264 KB) Pobierz
TECHNOLOGY IN ACTION
Beginning
LEGO MINDSTORMS
EV3
DISCOVER ALL YOU CAN DO WITH THE
NEW EV3 PROGRAMMABLE BRICK,
MOTORS, AND SENSORS
Mark Rollins
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
Contents at a Glance
About the Author �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½xiii
About the Technical Reviewer �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xv
Acknowledgments �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xvii
Introduction �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xix
Chapter 1: What’s New with LEGO MINDSTORMS EV3 �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½1
Chapter 2: Programming with the EV3 Language�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½29
Chapter 3: Creating a LEGO MINDSTORMS EV3 Vehicle �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½85
Chapter 4: Creating Visuals, Making Sounds, and Using Data on the EV3 Brick �½�½�½�½�½�½�½�½�½�½�½109
Chapter 5: Data Logging and Advanced Programming Blocks �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½141
Chapter 6: Special Construction Projects and Macros �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½159
Chapter 7: The LEGO MINDSTORMS EV3 Robot Arm �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½199
Chapter 8: Thinking like a LEGO MINDSTORMS Creator and the Walking Robot �½�½�½�½�½�½�½�½�½�½�½�½225
Index �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½249
v
Introduction
Have you ever looked at some new toy and thought: “I wish this had been around when I was a kid?” LEGO
MINDSTORMS are that to me, and much more. As someone who has been playing with LEGO since the first grade,
I would have gladly made programmable LEGO blocks my new favorite toy if they had come out in the early 1980s.
In case you haven’t figured it out, I am one of those guys that never really stopped playing with LEGO. I realize
that there are a lot like me out there, but hopefully you understand that I don’t greet someone I have never met before
with this fact about myself right away. If you think that adults that play with LEGO are people who need to grow up,
then you should take a look at what they can create.
That’s all I will say about that. I believe that the motivation to play with LEGO at any age comes from a desire
to create. Considering most of us don’t have the budget or materials to build an automobile in our backyard, it is
comforting to know that LEGO has given us the capacity to construct a mechanical marvel in our own living room, on
a smaller scale.
Why a book on LEGO MINDSTORMS EV3
The LEGO MINDSTORMS collection, first introduced in 1998, is one of LEGO’s top best-selling sets/series. The reason
for its success is the same as the reason for LEGO’s success before its release: the chance to kick your creativity
up a notch.
If you are like most avid LEGO enthusiasts, you don’t just purchase a LEGO set, build what is on the instructions,
and consider yourself done. If anything, you see the set as something to add to your collection. I’m not talking about
a room with shelves full of completed LEGO sets/models; I am talking about several boxes of LEGO pieces, with a
creator who is waiting for a brand new idea.
LEGO used to advertise in its catalog that just one set was capable of building all kinds of toys. Merging sets
creates infinite possibilities of creations. LEGO began offering special types of bricks so that creators could make their
creations automated, but even the later types of automated bricks (such as the Technic Power Functions) were still
rather limited with what you could do.
The problem is that LEGO Power Functions are all stop or go. For example, you can make a LEGO car that
could ride across the floor, but it could only go at one speed and then stop. You could even take control of it and
make it steer, but this also has limitations. Depending on what method of steering you use, you sometimes have to
deliberately jam the motors in order to make it work.
LEGO MINDSTORMS takes automation a step further by making these programmable parts. With
MINDSTORMS, you can make a model car go at different speeds, stop where you want it to, and turn where you
want, all with a simple program. In short, the MINDSTORMS series turned what was once a mere electronic toy for
amusement and turned them into programmable machines.
In this book, you will learn how to make many machines. As someone who has written two books about LEGO
Technic,
Practical LEGO Technics
and
LEGO Technic Robotics,
I can teach you how to build vehicles like cars as well as
other robotic machines. I will also teach you how to program these creations.
xix
IntroduCtIon
The History of LEGO MINDSTORMS
In order to understand LEGO MINDSTORMS, one should know the history of these technical LEGO creations.
By 1984, LEGO was already a household name, thanks to its unique blocks whose success can be seen by their
number of imitators. In October of 1984, then president and CEO of LEGO, Kjeld Kirk Kristiansen, saw a television
broadcast of children using Seymour Papert’s LOGO programming language to make robot turtles. Fascinated with
the idea of programmable LEGO toys, Kristiansen sent a team to the MIT Media Lab in Boston.
Two years later, in 1986, both LEGO Education and MIT produces LEGO TC LOGO, which allows users to control
models built from LEGO pieces. They create a special version of the LOGO computer language to program the
software. As for the hardware, it uses an interface box to send signals to LEGO motors and receive information from
sensors. In that same year, the product development department, LEGO Futura Boston Branch, works with the MIT
Media Lab to create the first working prototype of a programmable brick.
The first MINDSTORMS kit did not arrive to the market until 1998. You might be wondering why it took so long
(12 years) from the concept of a programmable brick to an actual product. This was because fewer homes had PCs
back in 1986, and the price of the electrical components was high. With the advent of the Internet and computers
being a requirement for most homes, the time was finally at hand for the first MINDSTORMS kit to hit the market.
The 1998 Kit introduced LEGO users to the RCX, a LEGO microcomputer that was the heart of the first
MINDSTORMS system.
The RCX code ran on Microsoft Windows (and eventually on Mac) and had ROBOLAB, LEGO MINDSTORMS
for schools, based on software from National Instruments LabVIEW, developed by Professor Chris Rogers of Tufts
University.
One year later, in 1999, the LEGO Group partners with FIRST (For Inspiration and Recognition of Science and
Technology) in order to create on the LEGO League. The LEGO League still goes strong until this day, and maintains
its goals of inspiring young people’s interests in science and technology through engaging, hands-on, and minds-
on experiences. Every year there are tournaments with different challenges, and LEGO MINDSTORMS are used to
overcome those challenges.
The success of the first generation of LEGO MINDSTORMS eventually leads to version 2, released in 2006.
This LEGO MINDSTORMS: NXT has new and improved software, wireless Bluetooth technology, expanded sensor
capabilities, and more challenges to encourage its users, especially the young ones, to create original ideas.
The software with NXT is also powered by National Instruments LabVIEW, but this program is very visual, with
icons representing different commands that a robot can perform.
The NXT 2.0 sets are also a hit, and Carnegie Mellon creates 18-week curriculums for it, with an emphasis on
programming basics as well as STEM (Science, Technology, Engineering, and Math).
In 2013, LEGO MINDSTORMS unveils the EV3, or third generation (the EV3 stands for “evolution”). With the new
version comes a more intelligent brick, new motors and sensors, and an improved icon-based programming.
Books from Apress about LEGO MINDSTORMS
Since LEGO MINDSTORMS was such a hit, there is no shortage of books from this publishing house. I wanted to take
some time to point them out, as I believe they will come in handy to the LEGO MINDSTORMS creator who is in need
of a few new innovations, or simply to compare the older versions of the programming language with the new.
Extreme MINDSTORMS An Advanced Guide to LEGO MINDSTORMS
By Michael Gasperi,
Ralph Hempel, Luis Villa, Dave Baum (Apress 2000). This is a book on how to build projects for
MINDSTORMS version 1. I have no idea how well it will work with EV3 models.
Dave Baum’s Definitive Guide To LEGO MINDSTORMS 2nd Edition
By Dave Baum
(Apress 2002). This is another book that deals with the first version of MINDSTORMS, but it
might give you ideas for future MINDSTORMS EV3 projects.
xx
Zgłoś jeśli naruszono regulamin