The LEGO® MINDSTORMS® EV3 Discovery Book

Page 1

®

EXPLOR3R, a wheeled vehicle that uses sensors to navigate around a room and follow lines N The FORMULA EV3 RACE CAR, a streamlined remotecontrolled race car N ANTY, a six-legged walking creature that adapts its behavior to its surroundings N The

SNATCH3R, a robotic arm that can autonomously find, grab, lift, and move the infrared beacon N LAVA R3X, a humanoid robot that walks and talks N The

More than 150 building and programming challenges throughout encourage you to think creatively and apply what you’ve learned to invent your own robots. With The LEGO MINDSTORMS EV3 Discovery Book as your guide, you’ll be building your own out-of-this-world creations in no time!

about the author Laurens Valk is a member of the MINDSTORMS Community Partners, a select group of MINDSTORMS enthusiasts who help test and develop new MINDSTORMS products. One of his robot designs is featured on the EV3 packaging as a bonus project. His previous work, the best-selling LEGO MINDSTORMS NXT 2.0 Discovery Book, introduced tens of thousands of beginners worldwide to the powerful world of LEGO MINDSTORMS robotics. He blogs about robots at http://robotsquare.com/. Requirements: One LEGO MINDSTORMS EV3 set (LEGO SET #31313)

®

LEGO MINDSTORMS has changed the way we think about robotics by making it possible for anyone to build real, working robots. The latest MINDSTORMS set, EV3, is more powerful than ever, and The LEGO MINDSTORMS EV3 Discovery Book is the complete, beginner-friendly guide you need to get started. Begin with the basics as you build and program a simple robot to experiment with motors, sensors, and EV3 programming. Then you’ll move on to a series of increasingly sophisticated robots that will show you how to work with advanced programming techniques like data wires, variables, and custom-made programming blocks. You’ll also learn essential building techniques like how to use beams, gears, and connector blocks effectively in your own designs. Master the possibilities of the EV3 set as you build and program:

®

®

THE lego mindstorms EV3 Discovery Book

DISCOVER THE CAPTIVATING WORLD OF LEGO MINDSTORMS EV3!

THIS BOOK IS NOT AUTHORIZED OR ENDORSED BY THE LEGO GROUP. FOR AGES 1O+ Price: $34.95 ($36.95 CDN) Shelve in: Robotics/Hobbies T H E F I N E ST I N G E E K E N T E RTA I N M E N T ™

w w w.nostarch.com

valk

THE LEGO MINDSTORMS EV3 Discovery Book ®

a beginner’s guide to building and programming robots laurens valk

®


quick building reference chart (1:1)

LEGOÂŽ MINDSTORMSÂŽ EV3 (#31313) parts list 15

12x 13

10x 1x

3

5

12x 7

3

11

8x

4 9

13

1x

1x

4

4x

5 5.5 6 5

7

4x

1x

1x

2x

2x

4x

2x

3x

3x

1x

1x

2x

4x

6x

4x

8x

14x

17x

1x

2x

4x

4x

2x

2x

3x

6x

4x

1x

4x

3

4x

4

3x

4

4x

5 5.5

6 7

9x

4x

Long / 50 cm

5x

2x

1x

2x

4x

15 9x

4x

7

2x

22x 9

6x

11

3

8

2x

9

8

1x 3

9

4x

1x

Medium / 35 cm 8x

sensor operation modes

2x

touch sensor

color sensor

Short / 25 cm

4x

12x

color

reflected light intensity

ambient light intensity infrared sensor

beacon heading

proximity

remote

beacon proximity

6x

6x

4x

1x

4x

state

10x

12x

11x

9x

95x

38x

12x

2x

2x

28x

10x

2x

1x

1x

4x

4x

4x

6x

6x

6x

2x 2x

4x

1x

3x

3x

4x 2x

1x

1x

1x

3x

6x

3x

3x


about the author Laurens Valk is a robotics engineer based in the Netherlands, where he earned a bachelor’s degree in Mechanical Engineering from Delft University of Technology. He is a member of the MINDSTORMS Community Partners (MCP), a select group of MINDSTORMS enthusiasts who help test and develop new MINDSTORMS products. He started building robots with the EV3 system a year before its 2013 release, and one of his designs appears on the EV3 packaging as an official bonus robot. Laurens enjoys designing robots and creating tutorials to build and program them, so that robot fans around the world can re-create the designs and learn more about robotics. He has worked on several LEGO robotics books, including the best-selling first edition of this book, The LEGO MINDSTORMS NXT 2.0 Discovery Book (No Starch Press, 2010). He blogs about robots at http://robotsquare.com/.

about the technical reviewer Claude Baumann has taught advanced LEGO MINDSTORMS robotics in after-school classes for 15 years. He created ULTIMATE ROBOLAB, a cross-compiler environment that allowed graphical programming of LEGO RCX firmware, and with it conceived the world’s only selfreplicating program for the LEGO RCX (some call it a virus). More recently, he participated as a MINDSTORMS Community Partner (MCP) during the development of the new EV3 Intelligent Brick. He has been the assessor of various high school robotics projects and is the author of Eureka! Problem Solving with LEGO Robotics (NTS Press, 2013), several articles, and conference presentations. His special interest is robotic sound localization. The head of a network of high-school boarding institutions in Luxembourg (EU), Claude is married with three children and three marvelous grandchildren.


brief contents introduction.........................................................................................................................................................................xxi

part I

getting started

chapter 1 chapter 2 chapter 3 chapter 4 chapter 5

preparing your EV3 set............................................................................................................................ 3 building your first robot........................................................................................................................... 9 creating and modifying programs.......................................................................................................25 working with programming blocks: action blocks........................................................................... 35 waiting, repeating, my blocks, and multitasking............................................................................. 49

part II

programming robots with sensors

chapter 6 chapter 7 chapter 8 chapter 9

understanding sensors........................................................................................................................... 61 using the color sensor.............................................................................................................................75 using the infrared sensor.......................................................................................................................89 using the brick buttons and rotation sensors................................................................................... 97

part III

robot-building techniques

chapter 10 building with beams, axles, connector blocks, and motors........................................................ 105 chapter 11 building with gears............................................................................................................................... 121

part IV

vehicle and animal robots

chapter 12 Formula EV3: a racing robot...............................................................................................................141 chapter 13 ANTY: the robotic ant............................................................................................................................171

part V

creating advanced programs

chapter 14 chapter 15 chapter 16 chapter 17

using data wires.....................................................................................................................................199 using data operations blocks and my blocks with data wires................................................... 227 using constants and variables............................................................................................................245 playing games on the EV3.................................................................................................................. 253

part VI

machine and humanoid robots

chapter 18 the SNATCH3R: the autonomous robotic arm.............................................................................. 263 chapter 19 LAVA R3X: the humanoid that walks and talks............................................................................. 311 appendix A troubleshooting programs, the EV3 brick, and wireless connections......................................351 appendix B creating on brick programs.................................................................................................................359 index................................................................................................................................................................................... 365


2

building your first robot In Chapter 1, you learned that EV3 robots consist of motors, sensors, and the EV3 brick. To make it easy for you to understand how each of these work, you’ll begin with only some of them. In this chapter, you’ll use the EV3 brick and two Large Motors to build a wheeled vehicle called the EXPLOR3R, as shown in Figure 2-1. You’ll also add a receiver for the remote control. After you finish building the robot, you’ll learn how to navigate the EV3 by using its buttons and how to control your robot remotely.

using the building instructions The LEGO MINDSTORMS EV3 set contains many beams and axles, which come in a variety of lengths. To help you find the correct element, their lengths are indicated in the building instruction steps, as shown in Figure 2-2. To find the length of a beam, simply count the number of holes (in the figure, the beam’s length is denoted by the box with the “11”). To find the length of an axle, put it next to a beam and count the number of holes it covers (in the figure, the axle’s length is indicated by the circle with “3”). When connecting beams or other elements using pins, be sure to select the correct pin based on its color, as shown in Figure 2-3. This is important because nonfriction pins spin freely (and are useful for smooth hinges) while friction pins resist rotation (and are more useful for rigid constructions).

Figure 2-1: The EXPLOR3R moves around on two front wheels and a support wheel in the back.

Axle 3

Beam

11

Figure 2-2: Beams and axles come in different lengths, so be sure to pick the correct ones while building. Determine the length as shown here or use the diagram on the front inside cover.


building the EXPLOR3R Nonfriction pins spin freely.

Friction pins cannot spin freely. Figure 2-3: The EV3 set contains friction pins and nonfriction pins. While building with the instructions in this book, select the correct one based on its color.

Figure 2-4: Bill of materials for the EXPLOR3R

10 Chapter 2

To begin building, select the pieces you’ll need by referencing the bill of materials, shown in Figure 2-4. Next, assemble the robot as shown in the steps on the pages that follow.


building your first robot 11


12 Chapter 2


building your first robot 13


14 Chapter 2


building your first robot 15


16 Chapter 2


10

11

building your first robot 17


12

18 Chapter 2


13

14

Connect the cables as shown. (The cables aren’t actually colored, of course, but the colors help you see how to connect each cable.)

building your first robot 19


output ports, input ports, and cables Congratulations—you’ve finished building the EXPLOR3R! Now let’s talk about the wires you just connected to the EV3 brick. You connected the two Large Motors to output ports on the EV3, labeled B and C. Both Large and Medium Motors should always be connected to output ports—to port A, B, C, or D—as shown in Figure 2-5. Sensors should be connected to the input ports 1, 2, 3, or 4. (I’ll discuss sensors in detail in Part II of this book.) Your EV3 set has three types of cables: four short cables (25 cm, or 10 inches), two medium-sized ones (35 cm, or 14 inches), and one long cable (50 cm, or 20 inches). Always string the cables around your robot so as not to interfere with

Sensor

any rotating elements (like wheels), and make sure they don’t drag on the floor when the robot moves around. The EV3 brick has two USB connections. The one labeled PC at the top of the EV3 (see Figure 2-5) is used to transfer programs from your computer to your robot. The USB host on the side of the EV3 is used to connect external devices, such as a Wi-Fi Dongle, to the EV3. A microSD card slot next to the USB host port allows you to add to the 4MB of free space on the EV3’s built-in storage. (The built-in storage will be enough for everything we do in this book.)

navigating the EV3 brick Before you move on to programming in Chapter 3, let’s try using the buttons on the EV3 brick (shown in Figure 2-6) to navigate around the menus and to run stored programs.

Input ports 1, 2, 3, and 4 USB host port for connecting additional hardware

USB connection (labeled PC) for transferring programs to the EV3 brick

Large Motor Output ports A, B, C, and D

Figure 2-5: You connect motors to output ports and sensors to input ports. The USB connection labeled PC is used to transfer programs to the EV3.

20 Chapter 2


Brick status light

Recently used programs

File Navigation Run Recent

Brick Apps Settings

EV3 screen

Back Up Left

Right Down

Center

Figure 2-7: Turning on the EV3 brick with the Center button opens up a menu with four tabs. The Run Recent tab shown on the right contains recently used programs.

Figure 2-6: The EV3 screen, the EV3 buttons, and the brick status light around the buttons

turning the EV3 on and off To turn on the EV3, press the Center button, as shown in Figure 2-7. The brick status light should turn red while the EV3 starts up. Once startup is complete (in about 30 seconds), the status light should turn green and you should see a menu with four tabs on the screen. You’ll learn to use each of these menus in later chapters. Each tab contains a specific set of files or functions, listed here from left to right: Run Recent: This tab contains recently run programs. File Navigation: This tab contains a folder for each programming project you’ve transferred to the EV3. Inside each folder, you’ll find programs and related files, such as sounds. Brick Apps: This tab contains applications for viewing sensors and controlling motors manually or remotely. Settings: This tab lets you set user preferences, like Bluetooth visibility and sound volume.

Figure 2-8: Turning off the EV3 brick

To turn off the EV3, return to the Run Recent menu and press the Back button. When you see the power off icon, either select the check mark to turn the EV3 off or select the X to cancel (see Figure 2-8). If you’re turning off the EV3 in order to replace the batteries, be sure to wait until the red status light is off, or you’ll lose all programs that you sent to the EV3 since you turned it on.

building your first robot 21


selecting and running programs You can switch to any of the four tabs with the Left and Right buttons. Pressing the Back button takes you back to the Run Recent tab. You can select any item on a tab using the Up and Down buttons. To choose a selected item, press the Center button. EV3 robots begin performing their actions when you select and run a program that has been transferred to the EV3. Although you haven’t transferred a program to the EV3 yet, you can try running a sample program that is already on the EV3 brick, called Demo. To test your EXPLOR3R, run this program by navigating to the File Navigation tab and selecting the Demo program, as shown in Figure 2-9. If you’ve built everything properly, your robot should make some sounds, move forward, turn left twice, and display a pair of eyes on the screen. The green status light should blink while the program runs. To abort the running program, press the Back button. (Now that you’ve run the program once, it should appear on the Run Recent tab.) N o t e The Demo program is made using On Brick Programming, but you’ll run programs that you make on your computer in just the same way.

making your robot move with the remote control Once you’ve finished building a robot, it’s important to test its mechanical functions before you start programming in order to identify problems like missing cables or gears. You can manually control your robot’s motors with the Motor Control and IR Control apps, as shown in Figure 2-10. Motor Control lets you run each of the motors using the EV3 buttons. IR (Infrared) Control allows you to control the robot with a remote. Select IR Control on the Brick Apps tab, and use the infrared remote control to make your robot move (see Figure 2-10). Not only is this a simple way to test your robot remotely, but it’s also a lot of fun! N o t e The Infrared Sensor acts as the receiver for the infrared remote. You can’t use the remote without the sensor. The IR Control app requires the sensor to be connected to input port 4, which is how the EXPLOR3R is set up.

Figure 2-9: To run the Demo program, go to the File Navigation tab, select the BrkProg_Save folder, open it with the Center button, select the Demo program with the Down button, and press the Center button. You’ll find your own programs on the File Navigation tab as well. (In the figure, you can see a project I made called TestProject.)

22

Chapter 2


Figure 2-10: To activate Remote Control mode, navigate to the Brick Apps tab and select IR Control. If the screen doesn’t show Ch1 + 2 in the lower-right corner, press the Center button again. In this configuration, you control the motors connected to ports B and C with the remote set to channel 1. (The red slider is all the way at the top.)

conclusion In this chapter, you learned to work with two essential robot components: the EV3 brick and motors. When you ran the Demo program, the EV3 switched on the motors, which made the robot move. In Chapters 3 and 4, you’ll learn how these programs work, as well as how to make your own programs with the EV3 software. The Infrared Sensor and infrared remote control will return in Part II of this book.

building your first robot 23


9

using the brick buttons and rotation sensors In addition to the Touch, Color, and Infrared Sensors, the EV3 contains two types of built-in sensors: Brick Buttons and Rotation Sensors. You can use the Brick Buttons on the EV3 brick to control or influence a program while it’s running. For example, the program can ask you to press one of the buttons to choose what the robot should do next. Each of the EV3 motors has a built-in Rotation Sensor that determines the position of the motor, allowing you to precisely control wheels or other mechanisms. The sensor also measures the motor speed, making it possible to detect when a motor is moving slower or faster than intended.

using the brick buttons You can use the EV3 brick’s Up, Down, Left, Right, and Center buttons in your programs just as you use the Touch Sensor. You can make your robot respond by playing a sound when you press a particular button, for example. You can also make the robot wait for the button to be released or bumped (a press followed by a release). One interesting way to use multiple buttons in a program is to create a menu on the EV3 screen, letting you choose the next action in the program. The ButtonMenu program in Figure 9-1 plays one of three sounds based on which button the user presses. Two Display blocks show a simple menu on the screen, asking the user to choose whether the robot should say “Hello,” “Okay,” or “Yes.” Then, a Wait block (in Brick Buttons – Compare mode) pauses the program until the user presses either the Left, Center, or Right button.

Discovery #48: Long Message! Difficulty:  Time: When you display a long message on the EV3 screen, you might find that the screen is too small to display it entirely. Create a program that lets you use the Down button to scroll through your message. Hi n t Make the robot display some new text on the screen each time you press the button.

Discovery #49: Custom Menu! Difficulty:  Time: Can you expand the ButtonMenu program to make your robot do useful things besides playing sounds? Take three programs you made previously, turn them into My Blocks, and place them in the switch of the ButtonMenu program. Reconfigure the Display blocks to describe what happens as you press each button. Ti p   This technique is often used in robotics competitions because it provides a way to start different programs very quickly. To change the actions of each sub program, simply modify the blocks in each My Block.


Figure 9-1: The ButtonMenu program. The Wait block is configured in Brick Buttons – Compare – Brick Buttons mode, and the Switch block is in Brick Buttons – Measure – Brick Buttons mode.

Next, a Switch block (in Brick Buttons – Measure mode) determines which button is being pressed, and the robot plays the requested sound. After the Wait block completes, the Switch block runs so quickly that the button is still pressed by the time the Switch checks the button state, even if you release it right away.

using the rotation sensor When you tell the robot to move forward for three rotations with the Move Steering block, the vehicle knows when to stop moving because the Rotation Sensor in each EV3 motor tells the EV3 how much it has turned. The program can also tell you how fast a motor is currently turning by measuring how fast the motor position changes. You can use Wait, Loop, and Switch blocks in Motor Rotation mode to measure motor position (Degrees mode or Rotations mode) and motor speed (Current Power mode).

98 Chapter 9

motor position The motor position tells you how much a motor has turned since you started the program. Use the Port View app on the EV3 brick, navigate to motor B or C, and rotate the motors with your hands to see the sensor values change. When you first start Port View (or your own program), the sensor value is 0. The value becomes positive when you rotate a motor forward; it becomes negative if you turn it backward past 0, as shown in Figure 9-2. For example, if you rotate the motor forward by 90 degrees and then backward for one rotation (360 degrees), the motor should report a position of −270 degrees. You can use the position measurement to create a program that plays a sound if you turn one wheel 180 degrees forward by hand, as shown in Figure 9-3. A Wait block in Motor Rotation – Compare – Degrees mode waits until the Rotation Sensor value is greater than or equal to (≥) 180 degrees. Because these sensors are built into the EV3 motors, they are always connected to output ports (you use the motor on output port B in this program).


resetting the motor position

Forward:

Backward:

Figure 9-2: If you program a Large or Medium Motor to go forward, it turns in the direction of the blue arrow and the Rotation Sensor value becomes positive.

Now suppose you want to repeat the actions in the HandRotate program with a Loop block so that the sound plays again when you rotate the wheel another 180 degrees. The first sound plays when you rotate the motor forward by 180 degrees. But during the second run of the loop, the sound would play immediately because the sensor value is already greater than 180 degrees, which is not what you want. The solution is to reset the Rotation Sensor value to 0 at the beginning of the Loop, using a Motor Rotation block in Reset mode, as shown in Figure 9-4. (You’ll explore the other features of this block and the other Sensor blocks later in Chapter 14.) Run the program and verify that you hear the sound once each time you rotate the wheel 180 degrees forward.

rotational speed Output port

Motor Rotation – Compare – Degrees

Figure 9-3: The HandRotate program makes the robot say “Okay” once you

The Rotation Sensor calculates how fast a motor turns as a value between −100% and 100% based on the rate at which the motor position changes. The value is positive when the motor turns forward (blue arrow in Figure 9-2), negative when the motor turns backward (green arrow), and 0 when the motor is not turning. For the Large Motor, a Current Power sensor value of 50% corresponds to a rotational speed of 85 rotations per minute (rpm). You can reach this speed by rotating a motor with your hands or by using any of the Move blocks with its Power setting at 50%.

rotate motor B forward by 180 degrees. Note that the Wait block would do the same thing if you used Motor Rotation – Compare – Rotations mode with a threshold value of 0.5.

N o t e Current Power mode measures rotational speed; it does not measure current or power consumption!

Reset

Figure 9-4: The HandRotateReset program sets the sensor value to 0 at the beginning of each loop with the Rotation Sensor block in Reset mode. Note that the Play Type setting in the Sound block is Play Once (1) so that the program doesn’t wait for the sound to finish.

using the brick buttons and rotation sensors 99


Discovery #50: Back to the Start! Difficulty:   Time: Can you make a program that returns a motor to the position it was in when the program started? The robot should give you five seconds to turn the motor to a random

Has the motor been turned backward?

Yes

No

position manually, and then the motor should return to its starting point. Use the decision tree shown in Figure 9-5 as a guide for your program.

Switch on the motor in forward direction.

Wait until the motor position is greater than or equal to 0.

Stop the motor.

Switch on the motor in backward direction.

Wait until the motor position is less than or equal to 0.

Stop the motor.

Figure 9-5: The flow diagram for Discovery #50. How does the robot determine that a motor has been turned backward?

calculating the rotational speed You can calculate the speed measured in rotations per minute (rpm) using the Current Power value as follows: large motor rotational speed (rpm) = sensor value × 1.70 medium motor rotational speed (rpm) = sensor value × 2.67 For example, if the Current Power value of a Large Motor is 30%, the motor rotates at 30 × 1.70 = 51 rotations per minute. Because one rotation per minute is equivalent to six degrees per second, you can calculate the rotational speed in degrees per second (deg/s) as follows: rotational speed (deg/s) = rotational speed (rpm) × 6 In this example, you get 51 × 6 = 306 degrees per second.

Motor Rotation – Compare – Current Power

Figure 9-6: The PushToStart program

100 Chapter 9

measuring rotational speed in a program To measure rotational speed in a program, you use the Current Power mode of the Rotation Sensor, as shown in Figure 9-6. The PushToStart program uses a Wait block configured to pause the program until motor B reaches a sensor value of 30% (51 rpm). Then, a Move Steering block takes over at the same speed. Run the program and push EXPLOR3R forward with your hands until it begins to move by itself.

Discovery #51: Colored Speed! Difficulty:   Time: Create a program that continuously changes the brick status light color to green if motor B is rotating forward, orange if it’s rotating backward, and red if the motor stands still. Rotate motor B with your hands to test your program. Hi n t You’ll need a Loop block, two Switch blocks, and three Brick Status Light blocks.


understanding speed regulation So far, you’ve been using several kinds of green Move blocks to make your robot move. These blocks make the motors turn at a constant, regulated speed. When the motors slow down because of an obstacle or an incline, the EV3 supplies some extra power to the motor to keep it going at the desired speed. The Power setting on these blocks actually specifies the speed that the motors try to maintain. That is, a Large Motor turning at 20% speed (34 rpm) while performing a heavy task might consume more power than a motor doing a light task at 40% speed (68 rpm). When you don’t want the EV3 to supply that extra power to maintain constant speed, you can use unregulated speed.

seeing speed regulation in action To see the difference between regulated speed and unregulated speed, you’ll create a program that makes the robot drive up a slope, such as a table with one end lifted up in the air. First, the robot drives at unregulated speed for three seconds, and then it drives at regulated speed for three seconds. You need two Unregulated Motor blocks (one for each motor) from the advanced tab of the Programming Palette, with their Power setting at 20%, as shown in Figure 9-7. After

waiting for three seconds, you stop the motors by setting their power to 0%. To drive at a regulated speed of 20% (34 rpm), the program uses the Move Steering block that you’ve seen before. Place the EXPLOR3R on a tilted surface and run the SteepSlope program. You should find that the robot drives quite slowly up the slope during the first three seconds and that it goes faster during the next three seconds. During the first part of the drive, the EV3 switches on both motors and leaves them alone for the next three seconds. The robot runs slowly because it takes more power to drive up a hill than to drive on even terrain. During the second part, the Rotation Sensors tell the robot that it’s going slowly, prompting the EV3 brick to supply some extra power to get the robot back up to speed.

stopping a stalled motor If you try to slow down one of the wheels when a Move Steering block runs, you’ll feel that the robot tries harder to get back up to speed. This is fine for wheeled vehicles, but it’s often undesired for mechanisms that don’t make complete turns, such as a claw mechanism. To avoid this problem, you can use the Unregulated Motor block and the Rotation Sensor to detect when the motor is stalled (blocked), as demonstrated by the WaitForStall program (see Figure 9-8). The program switches on motor B at 30% power and waits for the speed to drop below 5%, indicating that the motor is stalled. If you run this program on the EXPLOR3R, your robot should drive in circles until you slow down the robot by blocking its path.

Unregulated Motor block

Figure 9-7: The SteepSlope program. Note that I used a Sequence Wire to split the program in two for better visibility, but you won’t need to do this in your program.

using the brick buttons and rotation sensors 101


Figure 9-8: The WaitForStall program turns motor B until it is stalled. Note that the first Wait block is required to give the motor some time to get up to speed—otherwise, the rotational speed would be 0 when the speed is first measured, causing the program to end immediately.

further exploration Now that you’ve learned how to work with all of the sensors in the EV3 set, you can create robots that interact with their environment. The EXPLOR3R is, of course, only one example. As you continue reading this book, you’ll build several robots with sensors, each of which will use sensors differently. So far, you’ve learned to use the components that are essential to create a working robot: the EV3, the motors, the sensors, and the programming software. The following chapters will explore each of these subjects in more detail so that you’ll be able to create increasingly sophisticated (and fun!) robots. In the next chapter, you’ll begin looking at how you can use the Technic building elements in the EV3 set to construct your own robots. The following Discoveries will help you explore more possibilities with the sensors you’ve seen in this chapter.

Discovery #52: Brick Buttons Remote! Difficulty:  Time: Remove the EV3 brick from your robot (leaving the cables connected), and create a program that lets you move the robot around by pressing the EV3 buttons. Make the robot drive forward if you press the Up button, go left if you press the Left button, and so on. Hi n t Use a Switch block in Brick Buttons – Measure – Brick Buttons mode.

102 Chapter 9

Discovery #53: Low Speed Obstacle Detection! Difficulty:  Time: Can you make your robot drive around the room and move away from obstacles without the use of the Touch, Color, or Infrared Sensors? Make the robot drive forward using Unregulated Motor blocks until it detects an obstacle. The robot should then reverse, turn around, and continue driving in a new direction. Hi n t The rotational speed of a motor drops when the robot runs into an obstacle.

Design Discovery #11: Automatic House! Building:  Programming: Have you ever built houses from regular LEGO bricks? Now that you know how to work with motors, how to use sensors, and how to make working programs, how about trying to build a robotized house with the EV3? Ti p   Use a motor to automatically open the door when someone presses the doorbell (the Touch Sensor), and set an intruder alarm that sounds when the Infrared Sensor sees someone. Use another motor to close and open the shutters based on the light level measured with the Color Sensor.


®

EXPLOR3R, a wheeled vehicle that uses sensors to navigate around a room and follow lines N The FORMULA EV3 RACE CAR, a streamlined remotecontrolled race car N ANTY, a six-legged walking creature that adapts its behavior to its surroundings N The

N SK3TCHBOT,

a robot that lets you play games on the

EV3 screen SNATCH3R, a robotic arm that can autonomously find, grab, lift, and move the infrared beacon N LAVA R3X, a humanoid robot that walks and talks N The

®

LEGO MINDSTORMS has changed the way we think about robotics by making it possible for anyone to build real, working robots. The latest MINDSTORMS set, EV3, is more powerful than ever, and The LEGO MINDSTORMS EV3 Discovery Book is the complete, beginner-friendly guide you need to get started. Begin with the basics as you build and program a simple robot to experiment with motors, sensors, and EV3 programming. Then you’ll move on to a series of increasingly sophisticated robots that will show you how to work with advanced programming techniques like data wires, variables, and custom-made programming blocks. You’ll also learn essential building techniques like how to use beams, gears, and connector blocks effectively in your own designs. Master the possibilities of the EV3 set as you build and program:

®

®

THE lego mindstorms EV3 Discovery Book

DISCOVER THE CAPTIVATING WORLD OF LEGO MINDSTORMS EV3!

More than 150 building and programming challenges throughout encourage you to think creatively and apply what you’ve learned to invent your own robots. With The LEGO MINDSTORMS EV3 Discovery Book as your guide, you’ll be building your own out-of-this-world creations in no time!

about the author Laurens Valk is a member of the MINDSTORMS Community Partners, a select group of MINDSTORMS enthusiasts who help test and develop new MINDSTORMS products. One of his robot designs is featured on the EV3 packaging as a bonus project. His previous work, the best-selling LEGO MINDSTORMS NXT 2.0 Discovery Book, introduced tens of thousands of beginners worldwide to the powerful world of LEGO MINDSTORMS robotics. He blogs about robots at http://robotsquare.com/. Requirements: One LEGO MINDSTORMS EV3 set (LEGO SET #31313)

THIS BOOK IS NOT AUTHORIZED OR ENDORSED BY THE LEGO GROUP. FOR AGES 1O+ Price: $34.95 ($36.95 CDN) Shelve in: Robotics/Hobbies T H E F I N E ST I N G E E K E N T E RTA I N M E N T ™

w w w.nostarch.com

valk

THE LEGO MINDSTORMS EV3 Discovery Book ®

a beginner’s guide to building and programming robots laurens valk

®


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.