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

Chapter 9: Building an Automatic Entrance Door

Automatic entrance doors are used at various places, such as malls, offices, and so on. At malls, they ensure contactless entry and timely opening and closing of the door, with no human interaction required. At offices, such doors are combined with employees' identifier (ID) cards and these doors open only when the right ID card is placed in front of the door sensor, or the door stays closed. This ensures the safety of all employees in the office premises as well as helping with attendance management. In this project, you will be applying the concept of a simple machine pulley and building an entrance door that only opens when certain colors are detected. You might have seen automatic doors at malls, offices, airports, metro stations, and other places in your everyday life. Usually, an infrared (IR) sensor is used to detect the presence of a human and open/close the door. In our case, we will use a color sensor.

Do you know that...

Technical requirements

In this chapter, you will need the following:

  • LEGO BOOST kit with six AAA batteries, fully charged
  • Laptop/desktop with Scratch 3.0 programming installed and an active internet connection
  • A diary/notebook with pencil and eraser

Building an automatic entrance door

Let's build a door by following the building instructions given next. This is what our door should eventually look like:

Figure 9.2

We'll proceed as follows:

  1. Let's start our construction by taking two 1x10 bricks to make the base, as illustrated here:

    Figure 9.3

  2. Then, take six connector pegs and connect them to the bricks, like so:

    Figure 9.4

  3. Now, take two 1x16 bricks and connect them to each other, as follows:

    Figure 9.5

  4. Then, take four 1x2 plates and connect them to both ends of the brick, as follows:

    Figure 9.6

  5. Take two 1x2 bricks and connect them to the plates, like this:

    Figure 9.7

  6. Now, mount this whole structure onto the blue bricks with connector pegs. Then, take two tubes with double holes and connect them with connector pegs, as illustrated here:

    Figure 9.8

  7. Take two connector pegs and two 2M cross axles with snap, and connect them to the brick, as shown here:

    Figure 9.9

  8. ...

Let's code the door to open under certain conditions

Let's first find out the number of rotations needed to open and close the door completely. Keep the motor power at 30% only. We will need the following number of rotations:

__________ rotations to open the door fully

__________ rotations to close the door fully

Great! Now, do the setup of your automatic door and the color-coded man, as shown in the following screenshot. Identify the right place for the man to stand so that the color sensor can detect the colors accurately. The sensor should be able to sense the color of the hat:

Figure 9.68 – Basic setup of the man and door

Let's first understand the basics of the color sensor and how it works. Your BOOST kit's color sensor can detect six different colors: red, blue, green, yellow, black, and white. It can detect color from a maximum distance of 3 cm. Let's now learn how to code. For sensor-based programming, the first...

Time for a challenge

Challenge #1

Assume that a door is fixed at an office and the owner wants to allow entry of only specific types of people into the office. So now, program your door to do the following:

  1. Open when it senses people with green and blue hats.
  2. Keep the door closed for people with red hats. Display Sorry, entry is restricted to such people.

You need to use the same man that you built using the BOOST elements. Keep changing the hat color to test it.

Challenge #2

Try to add more colored hats, such as black, white, and yellow hats, using your LEGO elements, and modify the list as follows:

  1. Open the door for people with blue, green, and yellow hats.
  2. Keep the door closed for people with white, black, and red hats. You can display the same warning message.

You can use more of these if-else statements and add to the decision-making capabilities of your BOOST robot for many such exciting projects.

Summary

In this chapter, you worked further with the color sensor and wrote programs for complex tasks with multiple decisions involved. You used an if-then block for the first time. You also wrote programs for different actions of the robot for different colors detected. A pulley mechanism was used to open and close the doors. You understood the practical application of automatic doors in this chapter. To further instill these concepts, you will be building and coding a candy dispenser in the next chapter that will dispense candy depending on the color-coded currency detected.

Further reading

Most companies give a radio-frequency identification (RFID)-based ID card to their employees so that it becomes easy to track their attendance as well as ensure entry of only authorized people into the office. You can find out more about how RFID works at https://lowrysolutions.com/blog/how-rfid-and-rfid-readers-actually-work/.

Ready-made RFID tags are available on the market. You can interface them with an Arduino programming board and build your own RFID-enabled items in the future.

lock icon The rest of the chapter is locked
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}