• Elementary
  • Lesson 24 – Pamper your Robot Pet Part 1

Lesson 24 – Pamper your Robot Pet Part 1

Lesson Description

In this lesson, you will learn: how to assemble the Vertical Robot, understand IR sensors, calibrate the IR sensors, and make a hand detection system with feedback via LEDs.

ACTIVITY 1:  ASSEMBLING THE VERTICAL ROBOT

We will see how to transform the Horizontal Robot into the Vertical Robot.

CODING STEPS

Follow the steps below:

  1. By far, your robot looks like this.
  2. Remove the Battery Holder Lock and then the Battery Holders. Gently unsnap from the edges.
  3. Remove the Castor Wheel from the Robot.
  4. Attach Castor Wheel to the Castor Plate.
  5. Attach the Battery to the Robot.
  6. Snap the Caster Plate to the back side of the Robot as shown.
  7. Mount the Battery Holders and the Battery Holder Lock to secure the battery.

ACTIVITY 2: MAKING A HAND DETECTION SYSTEM

In this activity, we will make the Quarky detect the hands.

Let us understand the IR Sensors. An infrared (IR) sensor is an electronic device that measures and detects infrared radiation in its surrounding environment. IR is invisible to the human eye.

Quarky has 2 IR sensors.

Let’s understand how they work.

An IR sensor consists of 2 LEDs: one which transmits the IR light and one which receives the IR light. When the IR rays are transmitted, they bounce from the

nearest surface and get back to the receiver LED. That’s how an IR sensor detects an object.

We can get the sensor values in PictoBlox based on that value. We can estimate whether there is an obstacle.

  1. If the sensor detects nothing, its output value is increased. This means that the sensor is active.
  2. If it detects an obstacle, its output value decreases. This means that the sensor is inactive.

We need first to calibrate the IR sensors, i.e., make sure they’re working fine. For that, we’ll make a script in PictoBlox to calibrate them.

CODING STEPS

Follow the steps below:

  1. Create a New file in PictoBlox App.
  2. Connect Quarky to PictoBlox.
  3. Go to the Variables palette and create two variables named L and R.
  4. Next, make the following script to update the variable value to the left and right IR sensor values.
  5. You will notice that it appears in the top-left corner of the stage. We’ll use the variables to determine the threshold value for our IR sensors.
  6. Note the values of the Left and Right IR sensors when no obstacle is there in front of the robot. For example, in the above case:
    1. L_High = ­­­­­­__________
    2. R_High = __________
  7. Note the value of the Left and Right IR sensors when you put your hands in front of the robot:
    1. L_Low = __________
    2. R_Low = __________
  8. Next, do the average to get the threshold value:
    1. L_T = (L_High + L_Low)/2 = __________
    2. R_T = (R_High + R_Low)/2 = __________
  9. Remember these values.
  10. Getting Feedback via LEDs: Now, to check if the value works fine for our sensors, let’s add a feedback loop, something that will indicate that the sensor has detected the obstacle.
    1. Add a when flag clicked block from the Events
    2. Go to the Sensors palette and add two set () IR sensor thresholds to () block and write the threshold value you found before.
    3. Next, add a forever block from the Control We’re using this block because we want to check if the sensor detects the line continuously.
    4. Then, add an if-else block inside the forever
    5. Next, go to the Sensors palette and add an is () IR sensor active? block inside the white space of the if-else The IR sensor will be active when it detects the obstacle.
    6. To indicate that the sensor is active, let’s light up one of the LEDs of the dot matrix. From the Display palette, add a set LED x () y () to () with brightness () block under the if arm of the if-else Set the color as RED from the drop-down by clicking the color circle on the block.
    7. Duplicate the block and drop it under the else arm of the if-else Set the color as GREEN.
    8. Duplicate the if block and change the sensor to IR-R.
    9. Run the program and test the code.

Table of Contents