Robot Pet
Assembling the Vertical Robot
We will see how to transform the Horizontal Robot into the Vertical Robot in this topic.
Assembly
- By far, your robot looks like this.
- Remove the battery holder lock and then the battery holders. Gently unsnap from the edges.
- Remove the castor wheel from the robot and attach it to the castor plate A5.
- Mount the castor plate on the backside of the board.
- Mount the battery holders and the battery holder lock to secure the battery.
- You can even place the cutout a.k.a the skin of the robot to make it look cuter. 🙂
Your vertical robot is now assembled and ready to run!
Activity 1: Making a Hand Detection System
In this lesson, we will make the Quarky detect the hands.
IR Sensors
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.
- If the sensor detects nothing, its output value is increased. This means that the sensor is active.
- 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.
Activity 2: Making a Robo-Pet
In the last topic, you understood how to calibrate IR sensors.
Why not make a robot pet that reacts when it is pampered with hands. The robot can detect the pampering using IR sensors, and act accordingly. The objective is to make the robot execute certain actions when it detects a hand:
- When the hand is detected on the Left sensor (IRL inactive), turn left.
- When the hand is detected on the Right sensor (IRR inactive), turn right.
- When the hand is detected on both the left and right sensors (Both IRR & IRL are inactive), introduce Quarky and smile.
- When nothing is detected (Both IRR & IRL are active), do nothing.
Lets Code
- Add a when flag clicked block from the Events palette.
- Go to the Sensors palette and add two set () IR sensor thresholds to () block and write the threshold value you found in the last lesson.
- Add set robot orientation as () block and set the orientation as vertical.
- Next, add a forever block from the Control palette. We’re using this block because we want to check if the sensor detects the line continuously.
- Then, add an if-else block inside the forever block.
- Next, go to the Sensors palette and add an is () IR sensor active? block inside the white space of the if-else block. The IR sensor will be active when it detects the black line. This means that its value should be greater than the threshold value. This block will essentially check if the sensor value is greater than the threshold value.
- Duplicate the if block and put it inside the two branches of the if blocks. Change the value to IR-L.
- Now we have four branches all indicating four conditions. Let’s go over it one by one.
- The first case is when no hand is detected. Add a clear screen block from the Display palette.
- The second case is when the IR-R sensor detects the hand. In this case, the robot will turn Left. Add go () at () % speed for () seconds block from the Robot palette. Set the direction to right and time to 0.3 seconds.
- The third case is when the IR-L sensor detects the hand. In this case, the robot will turn Right. Add go () at () % speed for () seconds block from the Robot palette. Set the direction to left and time to 0.3 seconds.
- Lastly, both sensors detect the hand. Make the Robot smile and play sound – Hi, I am Quarky using the play sound () until done block.
The code is complete.Run and test it.