Home IoT & Hardware Smart Robotics with LEGO MINDSTORMS Robot Inventor

Smart Robotics with LEGO MINDSTORMS Robot Inventor

By Aaron Maurer
books-svg-icon Book
eBook $26.99 $17.99
Print $38.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $26.99 $17.99
Print $38.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
  1. Free Chapter
    Chapter 2: Getting Started with the Robot Inventor Kit
About this book
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.
Publication date:
May 2021
Publisher
Packt
Pages
438
ISBN
9781800568402

 

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.

About the Author
  • Aaron Maurer

    Aaron Maurer, also known as “Coffeechug” is the STEM lead for 21 school districts in Iowa helping to expand STEM, Computer Science, Makerspace, and Purposeful Play into classrooms K-12. Aaron is also a former FIRST LEGO League coach for 8 years with much success working with phenomenal kids. He has a Master Educator License with endorsements in 5-12 Psychology – 163; 5-12 World History – 166; 5-12 American History – 158; 5-12 Computer Science – 278; PK-12 Talented and Gifted – 107; 5-8 Middle School Generalist – 182; and K-8 Computer Science – 277. Currently, Aaron is a member of ISTE Making It Happen Award; Lego Education Ambassador and Master Educator; PBS Digital Innovator and All-Star; PITSCO Tag Committee; Microsoft Innovator Educator Expert; Microsoft Innovative Educator Fellow; Global Learning Mentor (formerly Skype Master Teacher); Minecraft Global Mentor; and Makey Makey Ambassador. Finally, Aaron was a finalist for the Iowa Teacher of the Year in 2014.

    Browse publications by this author
Smart Robotics with LEGO MINDSTORMS Robot Inventor
Unlock this book and the full library FREE for 7 days
Start now