Learning LEGO MINDSTORMS EV3
By Gary Garber
5/5
()
About this ebook
- Optimize the use of multiple sensors to build a robot that navigates and interacts with its environment
- Work with both the Home Edition and the Educational Edition of the LEGO EV3 Mindstorms kit
- A practical guide with step-by-step building instructions to help you create your very own robot
This book is for the hobbyists, builders, and programmers who want to build and control their very own robots beyond the capabilities provided with the LEGO EV3 kit. You will need the LEGO MINDSTORMS EV3 kit for this book. The book is compatible with both the Home Edition and the Educational Edition of the kit. You should already have a rudimentary knowledge of general programming concepts and will need to have gone through the basic introductory material provided by the official LEGO EV3 tutorials.
Gary Garber
Gary Garber teaches Physics, Math, and Engineering at Boston University Academy. Gary is Past-President of the New England Section of the American Association of Physics Teachers and has led dozens of professional development workshops in education at both a local and national level. Gary runs the Boston University FIRST Robotics program. He has run and hosted numerous robotics workshops in VEX, Tetrix, and LEGO platforms. He has also run several LEGO robotics tournaments and spoken on robotics education at both local and national conferences. His robotics team has worked with Engineers Without Borders, NASA, and the National Science Teachers Association on a variety of engineering and education projects. He is currently an Educational Consultant working to develop new software tools for the classroom at the Tufts Center for Engineering Education and Outreach, which is a pioneer in LEGO Robotics Education. He currently resides in Massachusetts, USA, and when he is not playing with LEGOS, robots, or toy trains, he enjoys spending time with his wife Catalina and their two children, Alejandro and Leonardo.
Related to Learning LEGO MINDSTORMS EV3
Related ebooks
Getting Started with LEGO Robotics: A Guide for K-12 Educators Rating: 0 out of 5 stars0 ratingsPython Robotics for Kids: A Guide to Spike Prime Robot with Object-Oriented Programming: Robotics, #1 Rating: 0 out of 5 stars0 ratingsHealth Idea Building Instruction Guide for LEGO® Education SPIKE™ Prime 11 Boxing Rating: 0 out of 5 stars0 ratingsBuilding with Virtual LEGO: Getting Started with LEGO Digital Designer, LDraw, and Mecabricks Rating: 0 out of 5 stars0 ratingsCoding with Basher: Coding with Scratch Rating: 0 out of 5 stars0 ratingsBots! Robotics Engineering: with Hands-On Makerspace Activities Rating: 5 out of 5 stars5/5Designing Digital Games: Create Games with Scratch! Rating: 0 out of 5 stars0 ratingsExploring LEGO Mindstorms EV3: Tools and Techniques for Building and Programming Robots Rating: 5 out of 5 stars5/5SPIKE™ Prime 02.Hand Drill Building Instruction Guide Rating: 0 out of 5 stars0 ratingsSPIKE™ Prime Bonus 3. Dance Club Building Instruction Guide Rating: 0 out of 5 stars0 ratingsSPIKE™ Prime Bonus 2. Business Card Machine Expansion Building Instruction Guide Rating: 0 out of 5 stars0 ratingsSPIKE™ Prime 06. Gimbal Building Instruction Guide Rating: 0 out of 5 stars0 ratingsRobotics!: With 25 Science Projects for Kids Rating: 0 out of 5 stars0 ratingsSPIKE™ Prime 12.Coordinator Building Instruction Guide Rating: 0 out of 5 stars0 ratingsSPIKE™ Prime 08. Table Fan Building Instruction Guide Rating: 0 out of 5 stars0 ratingsBuild It! Robots: Make Supercool Models with Your Favorite LEGO® Parts Rating: 3 out of 5 stars3/5Scratch Projects for 11-12 year olds: Scratch Short and Easy with Ready-Steady-Code Rating: 0 out of 5 stars0 ratingsSPIKE™ Prime 07. Table Cleaner Building Instruction Guide Rating: 0 out of 5 stars0 ratingsScratch Projects for 10-11 year olds: Scratch Short and Easy with Ready-Steady-Code Rating: 0 out of 5 stars0 ratingsScratch 2.0 Game Development - HOTSHOT Rating: 1 out of 5 stars1/5The STEM Club Goes Exploring Rating: 4 out of 5 stars4/5Scratch Projects for 9-10 year olds: Scratch Short and Easy with Ready-Steady-Code Rating: 0 out of 5 stars0 ratingsArduino Robotic Projects Rating: 4 out of 5 stars4/5The Everything Kids' Scratch Coding Book: Learn to Code and Create Your Own Cool Games! Rating: 4 out of 5 stars4/5Building Your Own Robots: Design and Build Your First Robot! Rating: 0 out of 5 stars0 ratingsExtreme Bricks: Spectacular, Record-Breaking, and Astounding LEGO Projects from around the World Rating: 4 out of 5 stars4/5Coding for Minecrafters: Unofficial Adventures for Kids Learning Computer Code Rating: 0 out of 5 stars0 ratingsLibGDX Game Development By Example Rating: 0 out of 5 stars0 ratingsThe Robot Book: Build & Control 20 Electric Gizmos, Moving Machines, and Hacked Toys Rating: 4 out of 5 stars4/5SCRATCH Projects for 8-9 year olds: Scratch Short and Easy with Ready-Steady-Code Rating: 0 out of 5 stars0 ratings
Intelligence (AI) & Semantics For You
Algorithms to Live By: The Computer Science of Human Decisions Rating: 4 out of 5 stars4/5Artificial Intelligence: A Guide for Thinking Humans Rating: 4 out of 5 stars4/5Summary of Super-Intelligence From Nick Bostrom Rating: 4 out of 5 stars4/5Deep Utopia: Life and Meaning in a Solved World Rating: 0 out of 5 stars0 ratingsMastering ChatGPT: 21 Prompts Templates for Effortless Writing Rating: 4 out of 5 stars4/5Creating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5ChatGPT For Dummies Rating: 4 out of 5 stars4/5ChatGPT Rating: 3 out of 5 stars3/5The Secrets of ChatGPT Prompt Engineering for Non-Developers Rating: 5 out of 5 stars5/5Regression Analysis: An Intuitive Guide for Using and Interpreting Linear Models Rating: 5 out of 5 stars5/5The Alignment Problem: How Can Machines Learn Human Values? Rating: 4 out of 5 stars4/580 Ways to Use ChatGPT in the Classroom Rating: 5 out of 5 stars5/5Grokking Artificial Intelligence Algorithms Rating: 0 out of 5 stars0 ratings101 Midjourney Prompt Secrets Rating: 3 out of 5 stars3/5Impromptu: Amplifying Our Humanity Through AI Rating: 5 out of 5 stars5/5Prompt Engineering ; The Future Of Language Generation Rating: 3 out of 5 stars3/5TensorFlow in 1 Day: Make your own Neural Network Rating: 4 out of 5 stars4/52084: Artificial Intelligence and the Future of Humanity Rating: 4 out of 5 stars4/5The Roadmap to AI Mastery: A Guide to Building and Scaling Projects Rating: 3 out of 5 stars3/5Midjourney Mastery - The Ultimate Handbook of Prompts Rating: 5 out of 5 stars5/5What Is ChatGPT Doing: ... and Why Does It Work? Rating: 0 out of 5 stars0 ratingsThe Business Case for AI: A Leader's Guide to AI Strategies, Best Practices & Real-World Applications Rating: 0 out of 5 stars0 ratingsDeep Learning with PyTorch Rating: 5 out of 5 stars5/5
Reviews for Learning LEGO MINDSTORMS EV3
2 ratings0 reviews
Book preview
Learning LEGO MINDSTORMS EV3 - Gary Garber
Table of Contents
Learning LEGO MINDSTORMS EV3
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Engineering Notebook
The engineering design process
Content Editor features
New pages and page actions
Computer-aided Design and building instructions
LEGO Digital Designer
LDraw
Commenting on your code
Summary
2. Mechanical Design
Mechanical advantage
Motors
Large motors and gears
Writing a program
Bevel gears at right angles
Worm gear
Using wires and parallel threads
Summary
3. Drive Train and Chassis
Chassis
Skid-bot with the Retail kit
Caster-bot with the Educational kit
Tread-bot with the Retail kit
Tread-bot with the Educational kit
Programming the robot to move forward
Summary
4. Sensors and Control
Using sensors
Programming blocks
LEGO EV3 sensors
Touch Sensors
Color Sensors
Motor Rotation sensors
Gyro Sensors
Ultrasonic motion sensors
Infrared Sensors
Third-party sensors
Dexter Industries
Mindsensors
HiTechnic sensors
MATRIX motor controllers and metal parts
Vernier sensors
Summary
5. Interacting with EV3
Push buttons
IR remote buttons
Bluetooth control
Smart device control
Wi-Fi control
Summary
6. Output from EV3
Display
Image Editor
Display data
Brick lights
Legacy NXT/RCX lights
Sound
Music
Summary
7. Advanced Programming
Loop and the Motor Rotation sensors
Loop and the Gyro Sensor
Troubleshooting with the Gyro Sensor
Switch or two-level controller
Three-level controller
Subroutines or My Blocks
Arrays
Summary
8. Advanced Programming and Control
Distance controller
Infrared versus Ultrasonic
Proportional algorithm
Line following using the Color Sensor
Setpoint for line tracking
Two-level or bang-bang controller
Proportional line follower
Entering gain and speed
PID controller
Gyro Sensor
IR sensor navigation and beacon tracking
Tracking a circle
Triangulation
Summary
9. Experiment Software and Data Logging
Data logging software
Improving dead reckoning
Analyzing gain constants
Graphical programming
Other bang-bang controllers
Summary
10. Other Programming Languages
LabVIEW
Front Panel and Block Diagram
Programming blocks
Loops
Line following VI
Robot tools
Data
Front Panel and clean Block Diagrams
SubVIs
RobotC
Simple code
Commands
Variables
Remote control
Graphical programming
Summary
11. Communication between Robots
Enabling communication
Messaging
Follow the leader
Maintain a distance
Search and rescue
Completing the search
Summary
12. Advanced Robot – Gyro Boy
Concept of a balancing robot
The Gyro Boy model
Sensor feedback
Programming bugbears
The main program
The control program
The RST My Block
The gOS My Block
The GT My Block
The GG My Block
The GM My Block
The EQ My Block
The cntrl My Block
The CHK My Block
Summary
Index
Learning LEGO MINDSTORMS EV3
Learning LEGO MINDSTORMS EV3
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: January 2015
Production reference: 1200115
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78398-502-9
www.packtpub.com
Cover image by Gary Garber
Credits
Author
Gary Garber
Reviewers
Barbara Bratzel
Michael duPont
Jeroen Hartsuiker
David Lechner
Diego Kartones
Muñoz
Geoff Shannon
Commissioning Editor
Akram Hussain
Acquisition Editor
Neha Nagwekar
Content Development Editor
Susmita Sabat
Technical Editor
Vivek Arora
Copy Editor
Laxmi Subramanian
Project Coordinator
Neha Thakur
Proofreaders
Simran Bhogal
Stephen Copestake
Maria Gould
Ameesha Green
Paul Hindle
Indexers
Hemangini Bari
Mariammal Chettiyar
Monica Ajmera Mehta
Graphics
Valentina D'silva
Production Coordinator
Shantanu N. Zagade
Cover Work
Shantanu N. Zagade
About the Author
Gary Garber teaches physics, math, and engineering at Boston University Academy. Gary is the president of the New England Section of the American Association of Physics Teachers and has led dozens of professional development workshops in education at both the local and national levels.
Gary runs the Boston University FIRST Robotics program. He has run and hosted numerous robotics workshops in VEX, Tetrix, and LEGO platforms. He has run dozens of LEGO robotics tournaments and spoken on robotics education at both local and national conferences. His robotics team has worked with Engineers Without Borders, NASA, and the National Science Teachers Association on a variety of engineering and education projects.
He is currently an educational consultant, working to develop new software tools for the classroom, at the Tufts Center for Engineering Education and Outreach, which is a pioneer in LEGO Robotics Education. He is the author of Instant LEGO MINDSTORMS EV3, Packt Publishing. He currently resides in Massachusetts, US. When he is not playing with LEGO, robots, or toy trains, he enjoys spending time with his wife, Catalina, and their two children, Alejandro and Leonardo.
I would like to thank the people of the Tufts Center for Engineering Education and Outreach for teaching me about LEGO robotics and helping make this book possible, including Chris Rogers, Ethan Danahy, Barbara Bratzel, and Bill Church. I would like to thank the students of Boston University Academy, in particular, the class of 2016, who remind me of how much fun students of all ages can have with LEGO. I would also like to thank Alejandro and Leonardo for reteaching me how to play with LEGO and making me watch the LEGO movie over and over again.
About the Reviewers
Barbara Bratzel is a science teacher at the Shady Hill School, a PreK-8 independent school in Cambridge, Massachusetts. In addition, she is a consulting teacher at the Center for Engineering Education and Outreach at Tufts University. Her most recent book, STEM by Design, a collection of classroom activities using the LEGO EV3, was published in February 2014.
Michael duPont is a maker, pilot, and theatre technician based in Central Florida. He recently graduated from Centre College in Danville, Kentucky. His specialties include microcontrollers such as the Raspberry Pi and Arduino, robotics, wearables, and other small electronics. You can find many of his open source projects on GitHub and on his website (http://mdupont.com/).
Jeroen Hartsuiker (born in 1971) played with LEGO Technic until his early teens. His dark ages (time when a person stops collecting and using the Danish bricks) ended while visiting LEGOLAND Billund in 1998, when he attended a workshop exploring the first generation of the MINDSTORMS Robotics Invention System. Since then, he has owned and used every generation of the LEGO robot, and he wrote courseware and delivered a presentation on how to control the MINDSTORMS NXT robot using Microsoft® Robotics Developer Studio. He occasionally contributes a module to the Great Ball Contraption (GBC) at LEGO WORLD in the Netherlands. Furthermore, a MINDSTORMS robot is sometimes used to make the software-development classes he teaches even more interesting. You can visit his blog at www.dotnetjes.nl.
David Lechner works mostly as a freelance computer programmer and occasionally as a Mad Scientist
teaching robotics as an after-school program in elementary schools. He also just completed his rookie year, coaching a FIRST LEGO League team, and has devoted much of his time to reverse engineering the EV3 as a core contributor to the ev3dev project. Prior to being self-employed, he spent 8 years doing industrial automation in the water and wastewater industry. He has a bachelor's degree in electrical and computer engineering from Oklahoma State University.
Diego Kartones
Muñoz, more commonly known by his nickname, Kartones, is a multidisciplinary developer who lives in Madrid, Spain. Having worked for more than 12 years with all kinds of desktop, mobile, and web applications, he has used quite a few languages such as C++, C#, PHP, and more recently, Ruby and JavaScript.
Regarding LEGO MINDSTORMS, he fell in love with RCX and then the NXT, both of which he liked to code in C instead of the default firmware and brick system. Now, with MINDSTORMS EV3, he seeks to code robot logic in Node.js. He's also been a technical reviewer for LEGO Mindstorms EV3 Essentials, Packt Publishing.
He loves learning about anything he comes across and keeps a few blogs. He sometimes speaks at events or user groups, and he would love to do more open source work. He can be reached at http://portfolio.kartones.net.
I'd like to acknowledge my girlfriend and my cats, for without their patience with my endless hours around computers and technology, I wouldn't be so happy.
Geoff Shannon has been an enthusiastic hardware hacker from a young age; his first job was building automated production equipment with Provel Inc. He has a bachelor's degree in computer science and recently attended a batch at Hacker School in New York City. In late 2013, he started working with LEGO robots by exploring the leJOS project and using it to run a Clojure REPL on his EV3. He currently lives in Seattle, WA, working as a software engineer.
To see what Geoff is currently working on and thinking about, check out his blog at www.zephyrizing.net. You can also follow him on Twitter at @RadicalZephyr.
www.PacktPub.com
Support files, eBooks, discount offers, and more
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Free access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
Preface
Welcome to Learning LEGO MINDSTORMS EV3.
The LEGO MINDSTORMS EV3 is a programmable LEGO brick that can control motors and receive feedback from a wide range of sensors. In this book, you will learn how to write programs in the LEGO MINDSTORMS EV3 software. This book is a practical guide that will show you how to advance beyond the basic lessons included in your EV3 kit, combine core programming commands, and implement tested design principles when building your own robot using the LEGO MINDSTORMS EV3 kit. You will become familiar with resources beyond your EV3 kit and enhance your robot designs.
The MINDSTORMS EV3 kit contains over 500 plastic interlocking parts. These parts are made with high-precision moulds. The LEGO Technic bricks in your kit include beams, axles, pines, gears, shafts, and bushings that will allow you to design a wide variety of robots. The LEGO bricks in your LEGO MINDSTORMS kit are compatible with all LEGO bricks made over the past 50 years.
The LEGO MINDSTORMS EV3 Intelligent Brick contains an ARM9 processor running Linux. This allows you to program the brick with a wide variety of languages, such as C, C++, Java, Python, and LabVIEW, but we will focus on the official LEGO MINDSTORMS EV3 software. This software is a visual programming language. Programming in the LEGO MINDSTORMS EV3 software consists of dragging-and-dropping blocks onto a programming canvas. You draw wires to connect the command blocks, such as command flow wires and data wires. There are blocks that store data, control motors, acquire sensor data, and initiate flow structures such as loops and switches. The beauty of a visual programming language is that with a programming hierarchy, you can create easy-to-follow programs where you can visually see the entire program at once.
The EV3 Intelligent Brick connects to motors and a wide variety of sensors, which LEGO builds via electrical wires, including Touch Sensors, Ultrasonic Sensors, Light Sensors, Infrared Sensors, and Gyro Sensors. The motors have built-in shaft encoders, which allow you to control exactly how far they turn. There is an even larger array of sensors produced by third-party vendors that you can use with your EV3. You can download and run your computer programs on the EV3 via a USB cable, Bluetooth, or Wi-Fi. All these features will take your LEGO MINDSTORMS EV3 beyond the category of a simple toy into an impressive robotics kit, which can be used to explore your environment and navigate a complex set of obstacles.
What this book covers
Chapter 1, Engineering Notebook, covers how to use the Content Editor to keep a multimedia record of your work building robots.
Chapter 2, Mechanical Design, covers how to use gears to increase either speed or torque in your robots.
Chapter 3, Drive Train and Chassis, explains how to build a chassis and attach either wheels or treads to create a moving robot.
Chapter 4, Sensors and Control, covers how to use sensors to receive feedback from your environment.
Chapter 5, Interacting with EV3, explains how to control your EV3 via the brick buttons, the infrared beacon, Bluetooth, and Wi-Fi.
Chapter 6, Output from EV3, covers how to send output from the EV3 brick using the display screen, lights, and the speaker.
Chapter 7, Advanced Programming, covers topics such as loops, switches, arrays, My Blocks, and navigation using sensor feedback.
Chapter 8, Advanced Programming and Control, covers advanced navigation techniques, including proportional controllers, PID controllers, course correction, and triangulation.
Chapter 9, Experiment Software and Data Logging, explains how to use the data logging features of the Educational Edition of the LEGO MINDSTORMS software.
Chapter 10, Other Programming Languages, provides a brief overview of RobotC and LabVIEW, which are the next steps up from using the LEGO MINDSTORMS software.
Chapter 11, Communication between Robots, explains how to send messages via Bluetooth to allow two EV3 robots to communicate, send commands, and collaborate.
Chapter 12, Advanced Robot – Gyro Boy, reviews and explains in depth the Gyro Boy program written by LEGO.
What you need for this book
You will need a LEGO MINDSTORMS EV3 kit to build the robots in this book. There are two versions of the kit: the LEGO MINDSTORMS EV3 Home Edition (Lego Set # 31313) and the LEGO MINDSTORMS EV3 Education Core Set (Lego Set # 45544). Both of these kits can be purchased for about $350. I have provided build instructions in this book, so you can build your robots no matter which set you have. The hardware differences include the type of wheels, treads, and casters. Between the kits, most of the pieces are the same but of different colors. The Home Edition has a Touch Sensor, Color Sensor, Infrared Sensor, and Infrared beacon. The Education Edition has a Touch Sensor, Color Sensor, Gyro Sensor, Ultrasonic Sensor, and a rechargeable battery. You can buy all of these parts at http://shop.lego.com/en-US/ or any general toy supplier.
If they did not come with your kit, you may want to buy the following:
EV3 rechargeable battery (Part # 45501), which is $60
EV3 Ultrasonic