Book Image

Build and Code Creative Robots with LEGO BOOST

By : Ashwin Shah
Book Image

Build and Code Creative Robots with LEGO BOOST

By: Ashwin Shah

Overview of this book

LEGO BOOST is a feature-rich creative toolbox that helps kids to develop science, technology, engineering, and mathematics (STEM) skills in a fun way. The LEGO BOOST kit consists of motors, sensors, and more than 840 LEGO pieces to bring various multifunctional robots to life. This book will take you on an interesting and enjoyable journey where you will have fun building robots while developing your problem-solving and logical thinking skills. This book is an end-to-end guide that will take you from a beginner to expert level of robot building with LEGO BOOST and Scratch. Starting with the unboxing and a brief introduction to LEGO BOOST, you'll quickly get your first robotic model up and running. You'll understand how to use the electronic and non-electronic components and have fun building a range of intriguing robotics projects with increasing complexity and advanced functionality. Throughout the book, you'll work on a variety of amazing projects, such as building your own R2D2, a fictional character from Star Wars, that will pique your curiosity to learn robotics and help you explore the full potential of the LEGO BOOST kit. Once you've had fun working with the projects, you'll be introduced to an interesting challenge for you to solve by yourself! By the end of this book, you'll have gained the skills to build creative robotics projects with the LEGO BOOST creative toolbox, and have built on your logical thinking and problem-solving skills.
Table of Contents (20 chapters)
Bonus Chapters

Running your tabletop fan at different speeds

Now, let's code our tabletop fan motor (motor C) so that it moves this way at 70% speed for 10 seconds when the green flag is clicked.


Break down your problem statement into small problems before approaching it!

Let's break our problem statement into smaller steps:

  • Step 1: Set the event to when the green flag is clicked.
  • Step 2: Set motor C's speed to 70 percent.
  • Step 3: Set motor C's direction to this way.
  • Step 4: Turn motor C on for 10 seconds.
  • Step 5: Turn motor C off.

If you break down your problem statement like this and write these step-by-step instructions each time, your coding job will be extremely easy and fun! Since this is your first time coding, please use the following sample code for this task:

Figure 2.21 – Sample program

Figure 2.21 – Sample program

Test it and see how much fun it is to use your fan to beat the summer blues!

Now, can you write some code that will move your tabletop fan motor C that way at 50 percent power for 10 seconds when the green flag is clicked?

Write down your problem steps here:

  • Step 1: ____________________________________________________________
  • Step 2: ____________________________________________________________
  • Step 3: ____________________________________________________________
  • Step 4: ____________________________________________________________
  • Step 5: ____________________________________________________________

Now, write your code and see how it works! Identify any errors and rectify them. Make sure that your code works exactly the way we want it to work!

Now that you know how to run your tabletop fan, the next section will test your skills.