Reader small image

You're reading from  Learning Lego Mindstorms EV3

Product typeBook
Published inJan 2015
Publisher
ISBN-139781783985029
Edition1st Edition
Right arrow
Author (1)
Gary Garber
Gary Garber
author image
Gary Garber

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.
Read more about Gary Garber

Right arrow

Chapter 5. Interacting with EV3

In this chapter, you will learn how to provide input to the robot. You will learn to interact with:

  • The Brick Buttons on the EV3 intelligent brick

  • The buttons on the Infrared Beacon

  • Bluetooth control using a smartphone

  • Wi-Fi communication

Push buttons


From the LEGO MINDSTORMS EV3 Help, you may be familiar with using Brick Buttons to start or stop an action. For instance, in the following program, the robot will move until a Brick Button is pushed.

Using the Brick Buttons to enter information will take some advanced programming and involve variables, case structures, and loops. Using the Brick Buttons on the EV3 brick, we are going to select the value for the speed of the robot. We are going to write a program that has a Switch block and a Loop to select the speed.

The program will begin by prompting the user with text displayed to the EV3 brick screen. To control how fast the robot moves, we will use a variable called Speed. The program then enters a loop to register each press of the Brick Buttons. When the loop is terminated, the updated value of the variable will be sent to a motor command.

First, we need to display commands for the user on the EV3 screen. Most of the first row of this program is used to send text to the...

IR remote buttons


The EV3 MINDSTORMS software Help provides good information on using the IR remote to control and send information to the robot. The following screenshot is an adapted version of what LEGO presents. Although the IR remote has only five buttons, the combination of buttons will allow you to send more commands than the Brick Buttons. Using different combinations of the IR remote buttons, the IR remote can send 11 different codes to brick; thus, you can actually have 11 different choices in a case structure.

In the preceding screenshot, I have written a code with six different choices in addition to the default choice in the case structure.

Bluetooth control


It is well worth while to pair your programming computer with your EV3 brick. This will save the need to tether the brick each time you want to download your code. If you are working in an environment where there is more than one EV3 robot, you should assign a unique name to the robot. This can be done via the tether. If you have enabled Bluetooth on your computer, you need to make the connection from the EV3 brick. Next, you need to enable Bluetooth on the EV3 brick. In the following screenshot of the EV3 brick display screen, you need to select Bluetooth from the settings menu on the EV3 brick.

The Bluetooth menu has several options. Make sure you have checked both Bluetooth and Visibility, as you can see in the following screenshot. When controlling the robot via Bluetooth from your computer, you have to disable or uncheck the iPhone/iPad/iPod option selected on your EV3 Brick. After checking the appropriate boxes, if you click on Connections, you will be able to search...

Smart device control


Using your smartphone or a tablet app to control your robot is easy. There are numerous apps for the older NXT MINDSTORMS robot kits; over time there will be several for the EV3. The official LEGO app is called LEGO MINDSTORMS Robot Commander, and is available on Google Play for Android and on the Apple App Store for the iPhone and iPad. When pairing with your smart device, you need to make sure to select the special iPhone/iPad/iPod option on the Bluetooth setting on your EV3 brick.

Robot Commander has controls ready to use for all of the robots from the Home Edition kit. However, you will want to create your own robot and controller. LEGO Commander will control assigned motors. You can create screen-based virtual joysticks, sliders, switches, or buttons. You can see the virtual joystick at the top left of the preceding screenshot. You can also use the accelerometers built into your smart device to control the robot's motors by tilting your smart device. LEGO Commander...

Wi-Fi control


Although a highlight of the EV3 set over the older NXT is that it is advertised to be Wi-Fi capable, this is something of an exaggeration. There is a USB port that allows you to insert a Wi-Fi dongle. The current versions of the firmware do not allow compatibility with many dongles. The Wi-Fi dongle recommended by LEGO is the only one I could find that would actually work. Additionally, you will need to design your robot so the dongle does not protrude from your robot in an awkward way. In the following image, you can see that I have a Wi-Fi dongle resting just above the motor. You could also use an angled USB adaptor, so your dongle does not protrude out of the side of the robot.

In addition to only a few choices for the Wi-Fi dongle, you need to make sure that you can successfully communicate with your router. In the preceding screenshot, you can see the Netgear WNA1100 dongle, sold by LEGO. For ease of use, you may want to set your router up without encryption or with WPA2...

Summary


In this chapter, you learned how to control and communicate with the EV3 robot by several different means. We controlled the robot using Brick Buttons, the Infrared Beacon, and smart device apps. You also saw that you can communicate wirelessly with the EV3 brick from your computer with either Bluetooth or Wi-Fi.

In the next chapter, we will explore various forms of output from the robot, including sound, lights, and the display.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Learning Lego Mindstorms EV3
Published in: Jan 2015Publisher: ISBN-13: 9781783985029
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.
undefined
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

Author (1)

author image
Gary Garber

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.
Read more about Gary Garber