Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Build and Code Creative Robots with LEGO BOOST

You're reading from  Build and Code Creative Robots with LEGO BOOST

Product type Book
Published in Nov 2021
Publisher Packt
ISBN-13 9781801075572
Pages 428 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Ashwin Shah Ashwin Shah
Profile icon Ashwin Shah

Table of Contents (20) Chapters

Preface Chapter 1: Introduction to the LEGO BOOST Kit Chapter 2: Building Your First BOOST Robot – Tabletop Fan Chapter 3: Moving Forward/Backward Without Wheels Chapter 4: LEGO BOOST Rover Chapter 5: Getting into Gear – My First Geared Robot Chapter 6: Building a Forklift Chapter 7: Building a Helicopter Chapter 8: Building R2-D2 Chapter 9: Building an Automatic Entrance Door Chapter 10: Building a Candy Dispenser Robot Chapter 11: Building a Color-Sorter Conveyor Belt Chapter 12: Building a BOOST Racing Car Chapter 13: Final Challenge Bonus Chapters
Chapter 14: The Grabbing Robot Chapter 15: Obstacle Avoidance Robot Chapter 16: The BOOST Humanoid Chapter 17: The Moon Rover Other Books You May Enjoy

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.

Tip

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.

You have been reading a chapter from
Build and Code Creative Robots with LEGO BOOST
Published in: Nov 2021 Publisher: Packt ISBN-13: 9781801075572
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}