Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Smart Robotics with LEGO MINDSTORMS Robot Inventor
Smart Robotics with LEGO MINDSTORMS Robot Inventor

Smart Robotics with LEGO MINDSTORMS Robot Inventor: Learn to play with the LEGO MINDSTORMS Robot Inventor kit and build creative robots

eBook
R$80 R$173.99
Paperback
R$217.99
Subscription
Free Trial
Renews at R$50p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Smart Robotics with LEGO MINDSTORMS Robot Inventor

Chapter 2: Getting Started with the Robot Inventor Kit

Let's get started with exploring the kit. We have over 900 elements to build robots, upgraded sensors, a new Intelligent Hub compared to previous versions, and new programming platforms to bring our robots to life and control:

Figure 2.1 – The front of the box when you get your hands on this amazing kit

Figure 2.1 – The front of the box when you get your hands on this amazing kit

To begin with, we are going to examine what the new elements in this kit are for us to build within our designs, how the sensors have changed, and the new Intelligent Hub. As we explore, we will take a closer look at some excellent features of this kit to start learning more about this LEGO Mindstorms product.

Finally, we will do some exploration of the new programming interface and how we use code to bring our ideas to life. The end goal of this chapter is to make sure you understand all the possibilities and to build a foundation of basic knowledge of the kit to begin to build some of the exciting ideas to follow in the upcoming chapters. This would also be a perfect time to build some or all of the five robots that come with the software to see how everything works and operates. There is not any specific building in this chapter, but it serves as an understanding of what can be achieved with the parts.

In this chapter, we're going to cover the following main topics:

  • Overview of the kit
  • The Intelligent Hub
  • New elements
  • Sensors
  • Programming
  • Basic projects to learn more

Technical requirements

One of the creative constraints when designing the builds in this book is to only use the parts, sensors, and elements contained in the kit. There will not be any additional parts needed to complete any of these builds. You will need LEGO Mindstorms Robot Inventor Kit 51515.

For software, you will need to download the LEGO Mindstorms Inventor software on either your computer, phone, or tablet. Please check the site to ensure your hardware is compatible with the software. You can find all hardware compatibility information on the LEGO site at https://www.lego.com/en-us/service/device-guide/mindstorms-robot-inventor.

You can access the code for this chapter here: https://github.com/PacktPublishing/Smart-Robotics-with-LEGO-MINDSTORMS-Robot-Inventor/blob/main/Chapter%202%20Rock%20Paper%20Scissors%20Code.lms.

If you would like a more detailed photo-by-photo build process of the robot, please head here: https://bit.ly/3eS6Cif.

Overview of the kit

This kit comes with 949 elements to build, design, and bring your ideas to life. When you open the box, you will find that the inside of the box has outlines to organize your elements. However, I don't think that many will use this grid unless you are crafty and install some cardboard walls to make it usable. Additionally, to have both box pieces on a table occupies a lot of space. While a nice feature, it is better if you use a leftover Mindstorms storage container or any other sorting trays you have sitting around. Or you could be like most people and just dump all the elements and spend time trying to find that one piece.

Coming from the space of education, I miss the plastic tub with sorting trays. The latest tub from SPIKE Prime has two trays that come together, which is super nice. I really wish we had this with this kit.

The kit does not have a manual to build robots, but the software comes with five robot builds to help a builder learn some new build techniques and to get started with building robots. The software provides the builder with the build instructions, then you connect the Intelligent Hub, download the software, test to make sure it works, and then modify to make the build and/or the code to your own style. It is quite nice once you get started with the software to see what it all provides.

Here is what the kit provides:

  • One micro USB cable
  • One Intelligent Hub
  • A sticker sheet
  • One base
  • 14 bags of building elements
  • External sensors (one distance sensor, one color sensor)
  • Motors (four small motors)
  • A booklet

We will explore these parts in greater detail throughout this chapter to understand them better.

The cables for motors and sensors

One of the biggest changes that the builder will notice right away is the cable connections. If you have not used SPIKE Prime and this is your first transition to the new Intelligent Hub, then you will notice that the cables are different. They are flat and smooth:

Figure 2.2 – Flat wires and wire clips

Figure 2.2 – Flat wires and wire clips

The kit comes with clips to help with wire organization and building, which is an excellent new upgrade to the building kits. No more rubber bands and looping cables. These clips are really nice to hide cables and manage them to allow your builds to look much more polished. The downside to these new cables is that these cables, sensors, and motors are no longer compatible with previous kits. If you are like me, then you'll have a lot of NXT and EV3 parts that you love that are no longer compatible with these new features. Another downside at this time is the cables are of fixed length. In previous kits, the cables were separate from the elements, so you had a wide range of wire sizes to fit your build. I am sure it won't be long before third-party companies create extensions, but in terms of the actual kit, all your wire lengths are the same, so plan your builds accordingly.

One other change to the kit from previous models is the lack of a remote. In previous models, you had an IR sensor and remote. In this kit, you use your phone or another Bluetooth-enabled controller. I don't think many will have any issues with this and will be excited to pair their Xbox or PlayStation controllers to their robots. The possibilities with Bluetooth are going to really open up some exciting features.

Let's dive into some specific parts and pieces worth exploring.

The Intelligent Hub

Another upgrade to this kit from previous versions is the size of the Intelligent Hub. The Hub is much smaller, which allows for more unique builds especially when combined with some of the new elements. The bulkiness of the EV3 and NXT is no longer going to be an issue. The way the Intelligent Hub is designed allows the builder to position the Intelligent Hub in a variety of ways to allow more easily building designs:

Figure 2.3 – The new Intelligent Hub that comes with the kit

Figure 2.3 – The new Intelligent Hub that comes with the kit

The LED screen is one of the most noticeable changes to the Intelligent Hub. In previous models, we had a screen where the programmer could program on the Intelligent Hub and have various elements of text, data, and graphical images displayed on the screen. On this Intelligent Hub, we are given a 5x5 LED screen. The days of programming on the Intelligent Hub are gone with this new design. However, keep in mind that it is now so much easier to get your programs to the Intelligent Hub. Once your Intelligent Hub is paired to your software, you can make changes instantly, so this feature is no longer needed.

The new Intelligent Hub has an LED design that reminds me of my 8-bit glory days of playing Tetris. These LED blocks allow you to gather some basic data on your sensors, then switch programs, and you are able to write out words that scroll across the screen. Additionally, you use the arrow buttons to scroll through your programs and you are able to store 10 programs.

Using the large button on the Intelligent Hub, you can gather some quick data and test your sensors and motors by plugging them in and gaining some quick information.

The Intelligent Hub has the gyro sensor built in. In the EV3, the gyro was a sensor we had to attach much like the touch, color, and ultrasonic sensors. This is a nice touch to the Intelligent Hub especially now that the Intelligent Hub has been reduced from eight ports to six. While at first you might be sad to only have six ports, remember this could prove to be helpful as these six ports can be both input and output. Looking back at the EV3, it had four ports for motors and four ports for sensors. The new Intelligent Hub allows the user to use any port for any motor or sensor. If you have been using EV3 for as long as I have, then you'll realize that this means you could potentially have six motors running off the hub or six sensors, whereas in the previous models, we were limited to four or fewer.

The Intelligent Hub also contains an accelerometer, an internal speaker, and a rechargeable lithium-ion battery. These functions expand the Intelligent Hub to allow the builder to do some really exciting projects. We will explore some of these features later, but it is a great reminder that the Intelligent Hub now serves as more than just the brains of the operation. It has several new features to expand what we can do with our robots without having to use ports. For example, you can now run your program tethered to your device or connect via Bluetooth for a wireless experience, as well as using your phone/tablet as a controller.

Elements

Depending on what previous LEGO Mindstorms kits you have used in the past and whether you have any experience with SPIKE Prime or some Power-Up kits, these elements might look familiar.

For the sake of exploring the kit, I would like to highlight a few key elements that I believe are great to have that the previous EV3 kit did not provide.

A quick note about the elements is that while many of the pieces are not necessarily new, there are several that come in the kit that are in a very nice-looking teal color. This will be a huge bonus for many builders looking to expand and coordinate their builds to have a more polished look. Teal is a great color choice, allowing the build designs to look really sharp. It is a great added color compared to the white, gray, and black of EV3 while not feeling too colorful like the SPIKE Prime. I like the colors of both kits, but I really like having choices in how my robots look.

Let's examine a few specific elements that come in the kit that are worth exploring a bit more deeply.

Panel plate

I fell in love with this piece when I purchased the SPIKE Prime kit. That kit provided two of these. The Robot Inventor provides one of these in that wonderful teal color, which is a very beautiful color scheme with this kit:

Figure 2.4 – The 11x19x1 panel plate

Figure 2.4 – The 11x19x1 panel plate

This plate allows the builder to build right upon it for stationary robots as well as a starting point for other robot builds, such as a vehicle or another mechanism. The possibilities this element provides the builder are huge. It is the piece I wish I always had.

Wheels

The kit provides six of these tires. These tires are great. They are all the same 56 mm size and are all black. They are one piece that is nice compared to the previous wheels. They are easy to clean for smooth driving and having six of these wheels to build with will allow the builder to build some excellent designs:

Figure 2.5 – This is the standard tire that comes with the kit

Figure 2.5 – This is the standard tire that comes with the kit

If you are looking for larger wheels that are built similar to these, there are a pair of larger wheels featured in the SPIKE Prime expansion kit.

Black frames

There are three sizes of these elements that come in the kit. These black frames provide a nice way to build some larger robots and to build more secure structures. You don't realize how much you need these elements until you build with them. Once you have them in your collection, you come to depend on them quite a bit:

Figure 2.6 – The three open frame sizes – from the top, 11x15, 7x11, and 5x7 – that come with the kit

Figure 2.6 – The three open frame sizes – from the top, 11x15, 7x11, and 5x7 – that come with the kit

Now that you have explored a few of the larger key elements, let's dive into some specific parts that are included in the kit.

Gear differential

The kit comes with a new gear differential that I know many builders will love. I do not have an extensive history with this aspect of building, but from what I have read and discussed, this piece will prove to be quite useful as builds on vehicles and robots are designed and built:

Figure 2.7 – Gear differential elements

Figure 2.7 – Gear differential elements

Some of you will love the gear differential, but not everyone builds with these parts. However, there are some parts that almost everyone will love having in the kit. Let's check some of these out.

Mudguards

I love that this kit comes with two mudguard elements. What I love about these elements, and all elements of LEGO, is that while the pieces were designed for a purpose, they can be remixed for all sorts of new ideas. As you explore the kit, consider how you can use pieces in new ways. For example, these elements could prove to be helpful in designing a moving mouth, handles to carry, the frame of a face, and so on:

Figure 2.8 – Mudguards

Figure 2.8 – Mudguards

While these are great pieces, here is another element in the kit that is even cooler!

Projectile launcher

This piece might be my favorite, but as an educator, it would easily be a headache! I know this kit does not come with a touch/force sensor, but the fact that it comes with two of these is great for coming up with new ideas. While there is fun in creating robots that shoot projectiles, such as Blast, which is one of the five builds, these can prove to be helpful in some other build ideas. And who doesn't love to launch projectiles?! This is a great addition to this kit to increase engagement and excitement:

Figure 2.9 – Projectile launchers

Figure 2.9 – Projectile launchers

Next, let's look at sensors!

Sensors

This kit is limited when it comes to external sensors. In previous kits, the builder was given a variety of sensors to use. Keep in mind that while this kit only provides two external sensors, there are sensors built into the Intelligent Hub. Overall, you are given the following sensors:

  • Inbuilt sensors:

    Gyro

    Accelerometer

    Timer

  • External sensors:

    Color sensor

    Distance sensor

The Intelligent Hub itself contains an accelerometer and gyroscope, which is great as you can use the data they collect to write some quality code with your robots. Another neat feature of the Intelligent Hub and these sensors are the gesture controls that allow the builder to create code based on tap, free fall, and shake using these sensors:

Figure 2.10 – The distance sensor on the left and the color sensor on the right that come with the kit

Figure 2.10 – The distance sensor on the left and the color sensor on the right that come with the kit

There are a few more details worth mentioning. The color sensor has been upgraded compared to previous versions. The color sensor is able to identify a small dose of color to make decisions. The sensor can also detect eight colors. Finally, it can identify these colors in both dark and bright light, which is very helpful. The sensor allows the coder to use color and reflection light.

The distance sensor is relatively similar to previous models except for a few changes. First, it has lights around the eye parts of the sensor that can be activated. The builder can program these lights, which is a cool feature.

The sensor is more accurate than previous models, but the range has been reduced from 250 cm to 200 cm. This will not impact many builders but is worth noting. You can choose distance settings of inches, centimeters, or percent.

Overall, the kit provides the builder with four motors and two sensors along with the sensors built into the Intelligent Hub itself, providing countless opportunities for building and coding.

Motors

This kit provides the builder with four motors. These motors have a top speed of 185 RPM along with a max torque of 18 Ncm. Additionally, the motors have sensors that allow you to gather data on both speed and position when using the app. One thing you will notice is that these medium motors are smaller than the medium motors of previous kits, but are much easier to build within your designs. This is a nice feature to allow the builder to create more fluid and precise builds. The shape also allows for easier builds than previous models where the motors had some unique shapes that could challenge how the builder created their creations:

Figure 2.11 – The design of the medium motors in the kit

Figure 2.11 – The design of the medium motors in the kit

The new motors are different from the NXT and EV3 motors. In the previous kits, you were able to put an axle all the way through the motor. These new motors do not allow the builder to do this build. At first, I did not like this, but I realized quickly that it did not prevent any builds from being successful.

One key advantage to these motors is their absolute positioning. This helps with the alignment of motors and to have more precise positioning when using robots that require motors to be synced.

Now that we have a better understanding of the elements of the kit, it is time to explore the software to bring the builds to life.

Hub connection

Using the Mindstorms software, you can adjust the sensor settings by clicking on the sensor icon and adjusting as needed. The following screenshots show how you can use the software to gather data on your motors and sensors and make the necessary adjustments to the needs of your build:

  1. In order to access the Hub connection, you will need to open up a new program or any existing program you have already started.
  2. In the upper right-hand corner, there is an Intelligent Hub icon that you will click on to open up the interface:
    Figure 2.12 – The Hub connection icon in the upper right-hand corner.

    Figure 2.12 – The Hub connection icon in the upper right-hand corner.

    You will notice a green dot on the upper right corner of the brick icon which means the Hub is connected. If the color dot is pink then that means your Intelligent Hub is disconnected.

  3. You will see this screen that will showcase all the motors and sensors currently plugged in and activated on the Intelligent Hub:
    Figure 2.13 – The software interface allowing you to see the data from inputs and outputs

    Figure 2.13 – The software interface allowing you to see the data from inputs and outputs

  4. Select a motor or sensor and click the white triangle below the icon to choose the various types of data readings that you can use for your projects:
    Figure 2.14 – The white triangle next to a data reading opens up a sub-menu of options

    Figure 2.14 – The white triangle next to a data reading opens up a sub-menu of options

  5. For the inbuilt sensors, click on the sensor you want to see the information for, and then move your Intelligent Hub around to see the data readings change:
Figure 2.15 – The four inbuilt sensor data readings for the Intelligent Hub

Figure 2.15 – The four inbuilt sensor data readings for the Intelligent Hub

Now that the Hub connection is done, let's move on to the coding!

Programming

When you boot up the software, you will have the choice to build any of the five robots already loaded up for you to build and use the code provided. Follow the instructions online provided in the software. If you need more information about the software and hardware and details about the kit, then head to https://www.lego.com/en-de/themes/mindstorms/about and you will get what you need from this page.

I find having the software on a computer or laptop for coding is quite helpful because of the larger screen and being able to store programs into my system. It is a good idea to have the software installed on your tablet or phone because these are good for the remote control feature of the software. Explore all the options to find what works best for you as a designer.

To get started, with version 10.0.3 (713488), LEGO updated the software to give you an option to get a quick overview of the sensors and builds and how they work with the Intelligent Hub. If you have any experience with Mindstorms, then you won't necessarily need this, but it is a great addition for those who are new to the Mindstorms robotics systems.

However, this little build and coding activity is a great start to explore much of the content shared in this chapter.

You can access this activity anytime by going to Settings | General and accessing the activity titled Welcome Robot Inventor:

Figure 2.16 – The Welcome Robot Inventor activity found in Settings

Figure 2.16 – The Welcome Robot Inventor activity found in Settings

Beyond this quick intro screen, you are prompted right away with the screen featuring the five robot builds, where you can choose any of them and build, code, and expand based on all the activities each robot provides.

This is a great time to explore these builds if you want to learn more about what this kit can do. These builds will give you ideas on how to build certain parts of robots as well as seeing how the coding platform operates. While this chapter has been mostly informative, take the time to build these models to experience what this robot kit is capable of making:

Figure 2.17 – The main screen with the five robot builds

Figure 2.17 – The main screen with the five robot builds

Once you have had your fill of those robots, then it is time to begin to build your own projects. When you are ready to create your own builds and programs, you can scroll down to Other and get started on your ideas.

You will have the choice to program with blocks or Python, as shown in the following screenshot:

Figure 2.18 – You can choose blocks or Python

Figure 2.18 – You can choose blocks or Python

When you choose Word Blocks, you will get a Scratch-like interface to explore and build. This is a drag-and-drop application. You can see how the software looks when you choose the block coding option:

Figure 2.19 – The coding platform looks like Scratch when you choose blocks

Figure 2.19 – The coding platform looks like Scratch when you choose blocks

The software is a Scratch-based programming platform. It uses a drag-and-drop coding process that many will already be familiar with if you have used Scratch, Blockly, MakeCode, or Code.org, and so you will be quite comfortable with the interface. The layout of colors on the black backdrop makes it easy to organize, find blocks, and explore the interface.

If you are looking to see even more blocks and add your Xbox or PlayStation controller, be sure to add the necessary extensions to your software by clicking on the gray-outlined blocks at the bottom of your screen, as shown here:

Figure 2.20 – Note the extensions at the bottom left of your screen to find these blocks

Figure 2.20 – Note the extensions at the bottom left of your screen to find these blocks

There is also a Python coding option within the software that will allow those who know how to program in Python to really push the boundaries of coding. This is a very important feature to bring this kit to the next level of experience and expertise. The following screenshot showcases what the Python coding interface looks like in the software if you wish to go down this route:

Figure 2.21 – Python coding interface within the software

Figure 2.21 – Python coding interface within the software

I know that not everyone knows how to code in Python, so for the sake of this book, we will stick with the graphical interface for ease of understanding.

Having both options to code and program within the software is a huge bonus to prior kits. The option for text programming is going to allow the LEGO community to see some incredible projects being developed.

If you are new to Python, there is a manual icon on the side of the screen to help you see how the blocks look in Python, named Knowledge Base:

Figure 2.22 – Find the Knowledge Base icon on the right side of the screen

Figure 2.22 – Find the Knowledge Base icon on the right side of the screen

Once you click on the Knowledge Base icon, you will be provided with a menu of options to help with your learning and coding journey. Simply choose the topic you need help with, as shown in the following screenshot:

Figure 2.23 – Expanded help options within the notebook

Figure 2.23 – Expanded help options within the notebook

The one fundamental difference to this programming environment compared to the LEGO SPIKE Prime kit is that lessons are missing. Of course, this is designed for retail instead of education like the SPIKE Prime, so that makes sense, but it's still worth pointing out. However, please check out the lessons to expand your skills as there is compatibility between the two. You can find the lessons here: https://education.lego.com/en-us/lessons?products=SPIKE%E2%84%A2+Prime+Set.

When you boot up the software, there are no introductions or any quick demos. Instead, you have to decide to build one of the five robots to get started, or hopefully, you have enough confidence to get started without guidance. One bonus of this software is that with each robot build, there are several activities to expand on the robots to learn some new build techniques and use to inspire the building of your own creations.

One crucial part of the programming software is being able to access data from your motors and sensors. You can access the Intelligent Hub through the software to gather all the data on your motors and sensors to be able to enhance your coding and build ideas.

On your software interface, at the top left of your screen, you can see some basic data or you can click on the Intelligent Hub icon to open up a new screen to dive deeper:

Figure 2.24 – Click the Intelligent Hub icon noted in this screenshot to access the data on your Intelligent Hub

Figure 2.24 – Click the Intelligent Hub icon noted in this screenshot to access the data on your Intelligent Hub

There is a ton of potential in this kit as you continue to explore and unravel all that can be accomplished.

Creating a rock, paper, scissors wrist game

So far, you have been doing a lot of reading, so let's take some time to do a quick build that covers some of the concepts shared about this new and exciting kit. You are going to build a fun little game of rock, paper, scissors that you can wear on your wrist.

You will need the following parts:

  • One Intelligent Hub
  • 12 black connector pins
  • One black 7x11 open frame
  • Two black 5x7 open frames
  • Two teal 9L beams
  • Two gray H connector brackets
  • Eight gray connector pins with a stop bush

To start this build, find your Intelligent Hub:

Figure 2.25 – Intelligent Hub

Figure 2.25 – Intelligent Hub

Locate four black connector pins. Flip the Intelligent Hub over to the back side and insert the four pins into the middle pin holes on the top and bottom of the Hub:

Figure 2.26 – Black pin connectors on the Intelligent Hub

Figure 2.26 – Black pin connectors on the Intelligent Hub

Locate your two black 5x7 open frame parts and attach the 5L side to the pins you just inserted into the Intelligent Hub:

Figure 2.27 – Open frames added to the Intelligent Hub

Figure 2.27 – Open frames added to the Intelligent Hub

It is time to locate the following parts:

  • Two teal 9L beams
  • Four black connector pins

Using two black connector pins with each 9L beam, secure the open frame and the Intelligent Hub with these beams:

Figure 2.28 – Black pins and 9L teal beams

Figure 2.28 – Black pins and 9L teal beams

Be sure to leave the bottom pin hole of the open frame open:

Figure 2.29 – 9L beams added to sides

Figure 2.29 – 9L beams added to sides

Repeat this process by doing the exact same thing and adding the it to the other side of the Intelligent Hub:

Figure 2.30 – Side view of the build so far

Figure 2.30 – Side view of the build so far

Locate the following parts:

  • One black 7x11 open frame
  • Four black connector pins:
Figure 2.31 – Open frame and black pins

Figure 2.31 – Open frame and black pins

Add two black connector pins to the middle pin holes on both sides of the 7L side of the open frame:

Figure 2.32 – Black pin added to the open frame

Figure 2.32 – Black pin added to the open frame

Connect this open frame to the bottom of the other open frames already connected to the Intelligent Hub:

Figure 2.33 – Open frame added to the bottom

Figure 2.33 – Open frame added to the bottom

You need to locate the following parts:

  • Two gray H connector brackets
  • Eight gray connector pins with a stop bush:
Figure 2.34 – Gray pins and H beams

Figure 2.34 – Gray pins and H beams

Insert four of the gray pins to the bottom two holes on each side of the H bracket. Do this to both of the parts:

Figure 2.35 – Gray pins added to H beams

Figure 2.35 – Gray pins added to H beams

Use these parts to secure the bottom open frame to the sides of this build. If you want to add this to your wrist, insert your wrist first and then secure it with these parts. If you have a tiny wrist, then hold onto the side so it does not fall off when you shake it playing the game!

Figure 2.36 – Completed build

Figure 2.36 – Completed build

This is a very simple build, but it is designed to be quick and easy to assemble to be able to play your first game of rock, paper, scissors. It is now time to write some code and play the game!

Coding a rock, paper, scissors wrist game

You are now going to code this wrist game to be able to randomly choose rock, paper, or scissors. You can play it against yourself or use it against another human. If you have a friend that has a kit, then you can both build one and compete this way:

  1. Using the default yellow when program starts block, add a purple Light block named write Hello. You will need to change the word from Hello to Left:
    Figure 2.37 – "Left" being programmed to screen

    Figure 2.37 – "Left" being programmed to screen

  2. Add two yellow Events blocks named when Left Button pressed. Make one that activates when the setting is set for the left button and the second block set for the right button.
  3. Go to the pink My Block sections of the coding blocks and make two new blocks. Name one start game and the other playagain. Add these new blocks to the yellow blocks. Add the start game block for the left button and playagain for the right button:
    Figure 2.38 – Decision making with MyBlocks

    Figure 2.38 – Decision making with MyBlocks

  4. In the previous step when you created these blocks, you should have seen two new pink blocks show up in your coding canvas named define playagain and define Start Game. Locate define playagain:
    Figure 2.39 – playagain My Block

    Figure 2.39 – playagain My Block

  5. Under the define playagain block, add a sound effect by adding a purple play sound block named play sound Cat Meow until done. Change the audio file to one of your choice. Under this block, add a Light block named turn on Smiley Face for 2 seconds. Click the face and change the graphic to your choice. In this example, an X was made. Add another light block underneath this one, turning off all the lights. Finally, add a final purple Light block named write Hello and change Hello to Left.
  6. You will follow a similar process for the other define Start Game block. Locate this pink block. Add a purple play sound block named play sound Cat Meow until done. Change the audio file to your choice. Add a purple Light block named turn on Smiley Face for 2 seconds. Change this block to the number 3 in the graphical interface and change it from 2 seconds to 1 second. Right-click the purple play sound block you just added and choose duplicate. Duplicate these two blocks two times so you don't have to keep dragging blocks. Change the 3 to a 2 and the other to a 1 to create a countdown timer. Last, create another pink My Block and name it Rps. Add this block to the end of this code:
Figure 2.40 – start game My Block

Figure 2.40 – start game My Block

The final step is to program the Rps block:

  1. Add a purple Light block named turn on and change the smiley face to the four squares in the corners.
  2. Add an orange Control block named wait until. Add a blue Sensor block of Hub is shaken to the diamond space.
  3. Go to the orange Variable block and make a variable named Rps_Random. Add the set Rps_Random block to the code. Use a green Operator block named Pick Random and select numbers 1-3.
  4. Add an orange Control block named If. Drag in a green Operator block that compares with the = sign. On one side of the equals sign, add your Rps_Random block, and on the other side, insert the number 1.
  5. Within that If block, add a purple Light block named turn on and turn on all the lights to symbolize paper.
  6. Add one more purple Light block named set Center Button light to and choose a color.
  7. Right-click this If block you just created and duplicate it two more times. For these two copies, change the numbers to 2 and 1. Change the design from paper (all lights) to a smaller square for rock for one, and for the other, design a pair of scissors.
  8. Add an orange Control block named Wait and choose 5 seconds so that you have time to see your game choice.
  9. Add a purple Light block named write Hello and change it to Right:
Figure 2.41 – Rps My Block

Figure 2.41 – Rps My Block

In the end, your code should look like this:

Figure 2.42 – Complete view of the code

Figure 2.42 – Complete view of the code

How it works is the game will tell you Left on the screen to indicate to press the left button. This will trigger the start game My Block, which will do a countdown timer to show your choice. Once it counts down, it will then move to Rps, where the code will wait for you to shake the Intelligent Hub before displaying a choice of rock, paper, or scissors. After it displays the choice for 5 seconds, it will then tell you Right, so when you press the right button, it will reset the screen and wait for you to press left again to play the game.

Making your own game

Consider how you can take this simple and classic game and make it your own. Here are some suggestions that will allow you to use your imagination and build up some skills as well:

  • Design your own icons for rock, paper, and scissors.
  • Convert this to a flip a coin (heads or tails) game.
  • Convert this game from rock, paper, scissors to the rolling of a die. Can you rewrite the code so that when you shake the Intelligent Hub it mimics the random roll of a die?
  • Add an option where you can choose from the three games to play/use.

Summary

To wrap up this chapter, let's do a quick review of what we covered. We explored the overall look of the new LEGO Mindstorms Robot Inventor kit. We examined the parts and elements that come with the kit, along with the sensors. Additionally, we took some time to look at the programming software.

Now that we have a basic understanding of the kit and some featured elements, let's finally get to the building of robots. Let's take what we have learned to start building some fun smart robots to challenge our thinking and creativity.

If you have not taken the time to build any of the five robots that are in the software, I would encourage you to take some time to build them and explore the ideas shared. None of these builds are required for the builds in this book, but they do provide a good foundation for the parts and building.

A few of these builds will reference certain build features from these five builds to showcase how these ideas inspire new ideas.

In the next chapter, we will start with a robot arm and claw, a classic build that is always great to build to explore the parts, programming, and use of sensors.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Gain confidence in building robots using creative designs
  • Learn advanced robotic features and find out how to integrate them to build a robot
  • Work with the block coding language used in robotics software in a practical way

Description

LEGO MINDSTORMS Robot Inventor is the latest addition to the LEGO MINDSTORMS theme. It features unique designs that you can use to build robots, and also enable you to perform activities using the robot inventor application. You'll begin by exploring the history of LEGO MINDSTORMS, and then delve into various elements of the Inventor kit. Moving on, you'll start working on different projects which will prepare you to build a variety of smart robots. The first robotic project involves designing a claw to grab objects, and helps you to explore how a smart robot is used in everyday life and in industry. The second project revolves around building a working guitar that can be played and modified to meet the needs of the user. As you advance, you'll explore the concept of biomimicry as you discover how to build a scorpion robot. In addition to this, you'll also work on a classic robotic challenge by building a sumobot. Throughout the book, you'll come across a variety of projects that will provide you with hands-on experience in building creative robots, such as building a Dragster, Egg Decorator, and Plankton from Spongebob Squarepants. By the end of this LEGO book, you'll have got to grips with the concepts behind building a robot, and also found creative ways to integrate them using the application based on your creative insights and ideas.

Who is this book for?

This book is for robot enthusiasts, LEGO lovers, hobbyists, educators, students, and anyone looking to learn about the new LEGO Robot Inventor kit. This book is designed to go beyond the basic build through to intermediate and advanced builds, and enables you to add your personal flair to the builds and codes.

What you will learn

  • Discover how the Robot Inventor kit works, and explore its parts and the elements inside them
  • Delve into the block coding language used to build robots
  • Find out how to create interactive robots with the help of sensors
  • Understand the importance of real-world robots in today s landscape
  • Recognize different ways to build new ideas based on existing solutions
  • Design basic to advanced level robots using the Robot Inventor kit

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 07, 2021
Length: 438 pages
Edition : 1st
Language : English
ISBN-13 : 9781800569980
Vendor :
Lego
Category :
Concepts :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : May 07, 2021
Length: 438 pages
Edition : 1st
Language : English
ISBN-13 : 9781800569980
Vendor :
Lego
Category :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
R$50 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
R$500 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$25 each
Feature tick icon Exclusive print discounts
R$800 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$25 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total R$ 775.97
Build and Code Creative Robots with LEGO BOOST
R$217.99
Mastering ROS for Robotics Programming, Third edition
R$339.99
Smart Robotics with LEGO MINDSTORMS Robot Inventor
R$217.99
Total R$ 775.97 Stars icon
Banner background image

Table of Contents

11 Chapters
Chapter 1: History of Mindstorms Chevron down icon Chevron up icon
Chapter 2: Getting Started with the Robot Inventor Kit Chevron down icon Chevron up icon
Chapter 3: Building an Industrial Robot Claw Chevron down icon Chevron up icon
Chapter 4: Building a LEGO Guitar Chevron down icon Chevron up icon
Chapter 5: Building a Scorpion Chevron down icon Chevron up icon
Chapter 6: Building a Solid Sumobot Chevron down icon Chevron up icon
Chapter 7: Building a Dragster Chevron down icon Chevron up icon
Chapter 8: Building an Egg and Ornament Decorator Chevron down icon Chevron up icon
Chapter 9: Creating Plankton from SpongeBob SquarePants – Part 1 Chevron down icon Chevron up icon
Chapter 10: Creating Plankton from SpongeBob SquarePants – Part 2 Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.8
(11 Ratings)
5 star 90.9%
4 star 0%
3 star 9.1%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Amazon Customer May 09, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I really enjoyed the look at how the LEGO robot program started and changed over time. There is so much helpful information for kids and AFOLs (Adult Fans of LEGO) alike. This is a great guide for individuals or use in a classroom. There are many different builds which is sure to have something for everyone!
Amazon Verified review Amazon
Murray May 08, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Aaron's book is great for leaneres of all ages. My nephew's (5 and 7) where guided through some great projects and they learned a lot along the way.The projects were diverse, also allowed us to remix and make them their own along the way. Being able to download the project files was a massive help too. I would recommend this book to the home audience wanting to do more with lego robotics as well as for the class room. Great work looking forward to the next one!
Amazon Verified review Amazon
Ishan Dec 29, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book helped me find out how to create interactive robots using sensors, and also know more about real-world robots, learned about robot Inventor kit.
Amazon Verified review Amazon
Kat Kelley Jun 16, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
My students thoroughly enjoyed creating and testing the "Rock, Paper, Scissors Wrist Game" project (I did too). They got so excited to play the game and then tried to see who's robot could win against the other robots. As a teacher, it was wonderful because it taught them how to use several sensors including the three-axis accelerometer and three-axis gyroscope included inside the Spike Prime hub - which is a new exciting feature.This book also includes instructions on how to make a "Remote Control Program" in the "Building an Industrial Robot Class" lesson which is unique to the LEGO Mindstorms Robotics Inventor kit. I would recommend this book for the classroom, or at home ideas for kids.
Amazon Verified review Amazon
Amazon Customer May 18, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Aaron's book is well written with easy to follow instructions and programming. I have been using LEGO Mindstorms for a while and this is a great reference for using the platform.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.