Grade 7_Robotics_Plus_ebook

Page 1


Tekie

Robotics Plus

Acknowledgements

Academic Authors: Neha Verma, Ayushi Jain, Anuj Gupta, Simran Singh

Creative Directors: Bhavna Tripathi, Mangal Singh Rana, Satish

Book Production: Rakesh Kumar Singh, Sanjay Kumar Goel

Project Lead: Jatinder Kaur

VP, Learning: Abhishek Bhatnagar

All products and brand names used in this book are trademarks, registered trademarks or trade names of their respective owners.

© Uolo EdTech Private Limited

First impression 2024

Second impression 2025

This book is sold subject to the condition that it shall not by way of trade or otherwise, be lent, resold, hired out, or otherwise circulated without the publisher’s prior written consent in any form of binding or cover other than that in which it is published and without a similar condition including this condition being imposed on the subsequent purchaser and without limiting the rights under copyright reserved above, no part of this publication may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without the prior written permission of both the copyright owner and the above-mentioned publisher of this book.

Book Title: Tekie Robotics Plus 7

ISBN: 978-81-983027-6-2

Published by Uolo EdTech Private Limited

Corporate Office Address:

85, Sector 44, Gurugram, Haryana 122003

CIN: U74999DL2017PTC322986

Illustrations and images: www.shutterstock.com, www.stock.adobe.com and www.freepik.com

All suggested use of the internet should be under adult supervision.

Robotics

What is Robotics?

Robotics is the study and creation of robots. Robots are machines that can perform various tasks. They are built using parts like metal, wires, and circuits, and programmed with special instructions to tell them what to do.

Some robots look like humans, while others are designed to work in specific places, like factories, hospitals, or even outer space! For example, a robot might assemble cars in a factory or explore the surface of Mars where humans cannot go easily.

Robots can sense their surroundings using sensors. These sensors act like the robot’s eyes, ears, and hands, helping it understand distance, temperature, or touch. Once the robot knows its surroundings, it can make decisions based on its programming.

The field of robotics combines science, technology, engineering, and mathematics (STEM) to solve problems and create amazing inventions. It is an exciting way to bring creativity and technology together!

Components of Robots

Robots are made up of different parts that work together to help them move, sense, and do tasks. These parts are grouped into three main types: mechanical, electronic, and coding interface. Let us learn about them.

Mechanical Parts

Mechanical parts are like the bones and muscles of a robot. They include wheels, gears, motors, and arms. These parts help the robot move, pick up things, or spin. For example, wheels let a robot roll around, and motors make robots move by turning wheels, spinning gears, or lifting arms.

Electronic Parts

The electronic parts are like the robot’s brain and nerves. They include circuits, sensors, and batteries. These parts help the robot think and sense its surroundings. Sensors act like eyes, ears, or even a nose for the robot, allowing it to detect light, sound, or obstacles. The battery gives the robot the power it needs to work.

Coding Interface

Coding is how we talk to robots and tell them what to do. Coding means writing instructions for them to follow. The coding interface is the program or app used to give these instructions. Once coded, the robot can move in a specific direction, stop when it sees something, or even dance.

By combining these three parts—mechanical, electronic, and coding—robots come to life and do amazing things.

Robotics Advanced Kit

About Robotics Advanced Kit 1

The Robotics Advanced Kit (RAK) is a comprehensive tool for young innovators who are curious to explore the subject of robotics. It features the Robotics FULL 2.0 BLE Brain, which powers the kit’s projects. The kit also includes exciting projects, encouraging creativity and problem-solving in students. With hands-on components and coding opportunities, RAK makes robotics fun-filled and accessible, inspiring students to think critically about robotics and innovate its programming. Let us explore its various components.

Electronics Parts

• Long Connecting Cable × 1 • USB Cable × 1

Construction Parts

Plastic Parts

1. FULL 2.0 Brain × 1 BLE
High Speed Motor × 2
High Torque Motor × 1
IR Sensor × 2
5. Touch Sensor × 1
Avishkaar Rechargeable Battery × 1 7. Adapter × 1
Manual Remote × 1
9. • Short Connecting Cable × 4
10. Male to Male DC Jack × 1

Metal Parts

A comprehensive metal design system allows you to make from easy to complex mechanical bot designs.

The Motors

Let’s understand how the motors work.

Robots move in different directions by the combination of the rotation from each wheel. For example: Robot Movement

Basics of Building

Let’s understand some basics of building:

Tightening Screws:

Tightening Axle Lock:

Tightening a Motor to a Plate:

Tighten (Rotate Clockwise)

Loosen (Rotate Anti-Clockwise)

Tighten (Rotate Clockwise)

Loosen (Rotate Anti-Clockwise)

About the Brain

Robotics FULL 2.0 BLE Brain

Let’s understand how the Full 2.0 Brain works.

Let’s understand how the Full 2.0 BLE Brain works.

the Ultrasonic Sensor to the brain.
This port powers the brain using the battery via Male to Male DC Jack.

Building a Remote Control Car

1 Insert the axle lock and the 3.5" axles into the high-speed motors, as shown.

2 After attaching the axles to both motors, screw them to the chassis using the 6mm bolts, as shown.

3 Repeat the previous step to attach the second high-speed motor to the other side of the chassis.

4 Add a filler to the axle, then add the wheel and at last add another axle lock. Do this for both axles.

5

Screw a 7.5 inch rectangular plate using 12 mm bolts with the first two holes of both the right and left sides of the chassis

6 Attach two U-Beams, one on top of the other using 6mm bolts. Then, screw the Caster wheel to both U-Beams using 2 K-nuts and 6mm bolts, as shown below.

7 Attach the previous assembly to the chassis as shown, with 12 mm bolts.

8 Screw the Battery at the bottom of the chassis using 6mm bolts as shown.

9

Screw the Brain to the chassis using 6mm bolts. Connect the Brain to the Battery using Male to Male DC Jack wire

About Coding Interface

10

Connect the left motor to the "M4" port and the right motor to the "M3" port of the Brain using the short connecting cables

The coding interface serves as the central hub for your kit, acting as an Integrated Development Environment (IDE) that enables you to write code for all of your experiments. This code is then transferred to the hardware.

The coding interface consists of the following components:

1. Workspace Area: This is where you drag blocks for the code you want to write.

2. Blocks Panel: The blocks from the Blocks Panel help make your code.

3. Share Code: The Share Code option in the File drop-down menu generates a link for the project to share with others.

4. Control Buttons: The Control Buttons consist of Save, Compile, and Connect buttons.

• Save Button: The Save button helps save your code.

• Compile Button: The Compile button helps compile your code.

• Connect Button: The Connect button helps burn your code to the hardware.

5. Arena: This is where you can see the output.

6. Buttons: The buttons help move the bot front, back, left, or right. The buttons also help rotate the bot clockwise and anticlockwise in the virtual arena.

7. Play Button: The Play button runs the code.

8. Reset Button: The Reset button resets the arena.

Burning Your Code

Burning means loading your code into the hardware. This process, mainly, has the phases as shown:

Arrange the blocks to create the code Save the code

Compile the code Burn the code

In case of error, recheck the code.

1. Once you have completed your experiment, connect the bot to a PC/Laptop using a USB cable or Bluetooth.

2. Save and compile your code by clicking on the Save and Compile buttons, respectively.

3. Now, click on Connect

4. Click on the USB Connect option or the BLE Connect (Bluetooth) option.

5. Click on the Connect Device button, and a small window will appear. Thereafter, select your connected device, and then click on Connect

6. Now click on Burn to write your program into the bot.

7. You have successfully written your code into the hardware. Now you can experiment on the bot.

Experiment 1: Bot Movements Using Motor Control 2

Objective

Learn how to control a robot by making it move forward, backwards, left, and right using motors. This helps in understanding the basics of how robots work and is a great start to learning robotics!

Background

In this experiment, the concept of time delay is used to suspend the execution of a program for a particular time. Let us understand this by looking at the process of cooking a dish in the microwave. Start

Put the dish in the microwave.

Set the timer of the microwave.

Take the dish out. Wait for the buzzer to beep.

Let’s Code

1. Click on the Control category from the Blocks panel.

2. Drag the My Program block to the workspace to begin your program.

3. Drag the Move Motor at the block from the Motor category and drop it inside the My Program block.

4. Configure the motor at Port4 (Advance) as clockwise by selecting the Clockwise option from the drop-down.

5. Select the speed of the motor as High, Medium, or Slow from the Speed drop-down.

6. Similarly, drag another Move Motor at the block and drop it below the previous block.

7. Select the Port3 (Advance) option from the drop-down menu.

8. Configure the motor at Port3 as anticlockwise by selecting the Anticlockwise option from the drop-down menu.

Select the speed of your choice from the Speed drop-down menu.

10. Drag the Time block from the Control category and drop it below the second Move Motor at block.

11. Type "2000" in the value box of the block. This will allow the forward movement of the motor for 2000 milliseconds or 2 seconds.

12. To move the bot forward for infinite time, use the Repeat while block from the Loops category with the Move Motor at blocks.

13. Similarly, to turn the bot backwards, configure the motor at Port4 as Anticlockwise and Port3 as Clockwise by making the respective selections from the drop-down menus.

14. To move the bot backwards for infinite time, use the Repeat while block from the Loops category with the Move Motor at blocks.

15. To turn the bot to the right, configure the motor at Port4 and Port3 as Anticlockwise and add a delay of 1100 ms by adding a Time block.

16. To turn the bot to the left, configure the motor at Port4 as Clockwise and Port3 as Clockwise too.

Note: When you turn the bot left or right, the time value may vary from system to system. Therefore, to make a 90 degree turn, you can configure the time value accordingly.

17. Give a name to your program, save it, and then compile it.

18. Now, the program is ready to burn on the RAK.

Scan QR code to view output

A. Tick () the Correct Option.

1 Which block is used to start your program?

a  My Program

c  Begin Program

2 The execution of all the blocks in a code occur

a  timely

c  in a loop

b  Start Program

d  Your Program

b  step by step

d  with delay

3 In which direction should the motors rotate to turn the robot to the left?

a  Both motors clockwise

c Left motor clockwise, right motor anticlockwise

B. Answer the Following.

b Both motors anticlockwise

d Left motor anticlockwise, right motor clockwise

1 How should the motors be configured to move the robot in the right direction?

2 What is the use of the "Repeat while" block?

C. Apply Your Learning.

1 Where can you see the applications of a moving robot in daily life?

2 What will happen in your project if you don’t use the "Repeat while" block?

Experiment 2: Edge Avoider 3

Objective

Using IR sensors, students will program their robots to smartly detect and avoid the edges of elevated platforms. This activity strengthens their understanding of sensor-based navigation while promoting problemsolving skills in practical scenarios.

Things Around Us

The concept of edge avoider is mostly used in the automatic vacuum cleaners.

Background

In this experiment, the following concepts are used:

1. Variables

• Variables are used to store information to be referenced and manipulated in a computer program.

• Variables in coding are not just static values; they also provide a way of labelling data with a descriptive name, so our programs can be understood more clearly. This data can then be used throughout your program. For example, i_count is the name of a variable.

2. Conditionals

• Human beings (and other animals) make decisions all the time that affect their lives, for eg. a. "Should I eat one cookie or two?"   b. "Should I play cricket or badminton?"

• Similarly, to make decisions and carry out actions accordingly, in our code, we use conditionals.

3. If block

• Conditional blocks have conditions, and the program’s flow is based on whether the condition is true or false.

• To apply conditions in code, use the if block. The if block has else if and else blocks.

• If the condition given in the if block is true, then the set of code is executed; otherwise, the code given in else if or else block is executed.

4. IR Sensor

• An infrared (IR) sensor is an electronic device that measures and detects infrared radiation in its surrounding environment. Everything around us, including our bodies and objects, gives off heat in the form of infrared radiation. Warmer objects emit more infrared radiation than cooler ones.

• In the IR sensor, the sensor state is high when a reflective object is in front of it. Black or dark-coloured objects do not reflect the IR rays.

Let’s Build

After creating the RC car, follow the given steps to create your Edge Avoider robot:

1 Connect the 7.5" U-Beam to the 2.5" U-Beam in the RC Car assembly using 12mm Bolts and K-Nuts.

2

Connect the IR Sensor to the 7.5" U-Beam using a Bolt.

3 Finally, the assembly for the Edge Avoider robot looks like the one shown below:

Let’s Code

1. Click on the Control category from the Blocks panel.

2. Drag the My Program block to the workspace to begin your program. The execution of all the blocks inside this occurs step by step.

3. Drag the Repeat while block from the Loops category and drop it inside the My Program block to begin the infinite loop. By default, the loop value is set as true

4. Click on the Variables category.

5. Click on the Create Variable button. A pop-up box appears.

• Enter a suitable variable name in the New variable name box like IR_Sensor.

• Click on the OK button. This will create a variable to store the data of the IR sensor value received from the sensor.

6. Drag and drop the set to block from the Variables category and place it inside the Repeat while block.

7. Then drag the Read IR Sensor at block from the Sensor category and place it next to the set to block. Set the value of the Read IR Sensor at block as Port5 (Advance).

8. Drag the if block from the Control category and place it below the set to block.

9. Click on the settings icon of the if block. A pop-up box appears.

10. Drag the else block and place it below the if block in the pop-up box (refer to the image below).

11. Again, click on the settings icon to hide the pop-up box.

12. Define the condition for the if block using the block from the Control category.

13. Drag the IR_Sensor block from the Variables category and drop it in the left value box of the block.

14. Select the '>' sign from the drop-down list of the block.

15. Drag the block from the Math category and drop it inside the right value box.

16. Type '400' in place of 0. If the value of the IR_Sensor variable is greater than 400, i.e., the IR Sensor senses the object, blocks under the if block will be executed, otherwise the blocks under the else block will be executed.

17. Drag and drop the Print Data block in the do part of the if block. Drag the empty Text Box block from the Text category and drop it inside the Print Data block. Type "Moving forward" in the Text Box block.

18. Now, we have to set both the motors to move in the forward direction when there is a surface below. For this, drag and drop two Move Motor at blocks from the Motor category. Configure the Motor at Port4 (Advance) as Clockwise and Port3 (Advance) as Anticlockwise.

19. Set the speed of both the motors to Medium

20. For the else part, drag and drop the Print Data block in the do part of the if block. Drag the empty Text Box block from the Text category and drop it inside the Print Data block. Type "Edge detected" in the Text Box block.

21. Set both motors to Stop by dragging and dropping the Move Motor at blocks.

22. Also drag and drop the Time block from the Control category to instruct the bot to stop for 500 milliseconds when there is no object or surface detected below.

23. Set both motors to move backwards followed by the left direction (you can turn the bot to any direction as you wish). This will instruct the bot to move back and then left when no object or surface is detected. Adjust the value in the Time block as shown.

24. Now, set both the motors to Stop.

25. Give a name to your program, save and then compile it.

26. Now, the program is ready to burn on the RAK.

Scan QR code to view output

A. Tick () the Correct Option.

1 What is the main purpose of using IR sensors in this experiment?

a  To avoid obstacles on the ground

b  To detect edges of raised platforms

c  To control the speed of the motors

d  To change LED colours

2 What does an IR sensor do when a reflective object is close to it?

a  Changes the LED to red b  Stops the motor

c  Sets the sensor state to HIGH d  Starts the program

3 Which block is used to apply conditions in code?

a  Repeat while block b  Move Motor block

c  if block d  My Program block

B. Answer the Following.

1 What are variables used for in a program?

2 How does the "if" block help in decision-making in code?

C. Apply Your Learning.

1 Imagine you are programming a robot to avoid puddles on the floor. Describe how you would use an IR sensor to detect puddles and make the robot change direction.

2 If your robot’s IR sensor detects an edge, how would you program it to stop and turn safely?

Experiment 3: Simple Crane 4

Objective

To demonstrate a lifting mechanism that lifts objects using a hook attached to a gear combination powered by a high-torque motor.

Things Around Us

Simple cranes are often used in construction projects and for lifting heavy objects.

Crane Machines

Let’s Build

1 Connect the Touch Sensor to the 7.5" Rectangle in the RC Car assembly using 12 mm Bolts.

2 Connect the 7.5" U-Beam to the 7.5" Rectangle using 12 mm Bolts and K-Nuts.

3 Connect the High Torque Motor to the 7.5" U-Beam using a 3.5" Axle, Axle Lock and Bolts as shown.

4 Connect the Small Spur Gear to the Axle using a Filler and an Axle Lock.

5 Connect the Axle to the U-Beam using an Axle Lock.

6 Connect a Big Spur Gear to the 12.5" Flexi using K-Nuts and 12mm Bolts.

7 Connect a Plastic Hook to the Flexi using a Nut and Bolt.

8 Now, connect the Big Spur Gear in the assembly from the previous step to the Axle in the assembly from step 5 using a Filler and an Axle Lock.

9 Connect the Touch Sensor to the Port S5 of the Brain using Connecting Cables. 10 Also connect the High Torque Motor to the Port M2 of the Brain

1. Click on the Control category from the Blocks panel.

2. Drag the My Program block to the workspace to begin your program. The execution of all the blocks inside this will occur step by step.

3. Click on the Variables category.

4. Click on the Create variable button. A pop-up box will appear asking you to enter a new variable name.

• Enter a suitable variable name, let us say “count”.

• Click on the OK button.

5. Drag the set to block from the Variables category and drop it inside the My Program block.

6. Then, drag the number block from the Math category and attach it to the set to block. By default, the number block is set to 0.

7. Drag the Repeat while block from the Loops category and drop it below the set to block to begin the infinite loop. By default, the loop value is set as true.

8. Now, create another variable by clicking on the Create variable button from the Variables category. A popup box will appear asking you to enter a new variable name.

• Enter a suitable variable name, let us say “touch”.

• Click on the OK button.

9. Drag another set to block from the Variables category and drop it inside the Repeat while block.

10. Drag the Read Touch Sensor at block from the Sensor category and attach it to the set to block. Select the “Port5 (Advance)” option from the drop-down menu of the Read Touch Sensor at block.

11. Drag the if block from the Control category and place it below the set to block.

12. Drag the equal operator block from the Control category and attach it to the right of the if block.

13. Select the “>” option from the drop-down menu of the equal operator block.

14. Drag the touch block from the Variables category and drop it in the left part of the greater than operator block.

15. Now, drag the number block from the Math category and drop it in the right part of the greater than operator block. Type “400” for the text part of the number block. Now, if the value of the touch variable is greater than 400, i.e., the touch sensor is pressed, then the blocks under the if block will be executed.

16. Drag and drop the set to block in the do part of the if block. Select the “count” option from the drop-down menu of the set to block.

17. Drag the add operator block from the Math category and attach it to the set to block.

18. Now, drag the count block from the Variables category and drop it in the left part of the add operator block. This will add a sum of 1 to the variable count every time the touch sensor is pressed.

19. Drag the Print Data block from the Display category and drop it below the set to block. Select “Row 3” from the drop-down menu of the block.

20. Drag the if block from the Control category and drop it below the Print Data block.

21. Click on the Settings icon of the if block. A pop-up box will appear.

22. Drag the else if block and drop it below the if block in the pop-up box twice. (Refer to the image below).

23. Click on the Settings icon again to hide the pop-up box.

24. Drag the equal operator block from the Control category and attach it to the if block.

25. Drag the count variable block and drop it in the left part of the equal operator block.

26. Drag the number block and drop it in the right part of the equal operator block. Type “1” in the text part of the number block.

27. Drag the Print Data block and drop it in the do part of the if block.

28. From the Text category, drag the Text Box block and drop it in the empty space of the Print Data block.

29. In the Text Box block, type “Moving Forward”.

30. Drag two Move Motor at blocks from the Motor category and drop them below the Print Data block. Configure the motors at Port4 (Advance) as Anticlockwise and Port3 (Advance) as Clockwise.

31. Select “Medium” option for the Speed from the drop-down menu of the Move Motor at blocks. Drag and drop the Time block below the Move Motor at block. Type “2000” in the text part of the block. This will move the bot forward for 2000 milliseconds (ms) or 2 seconds.

32. Similarly, drag and drop the blocks below the Time block to turn the bot to the left and then stop.

33. Similarly, set a condition for when the touch sensor is pressed twice or when the count variable becomes 2. This will enable the bot to lift an object using the crane. After lifting, the bot will then move forward and stop.

34. Similarly, set a condition for when the touch sensor is pressed three times or when the count variable becomes 3. This will enable the bot drop an object using the crane. The bot will then move left and stop. After stopping for 1 second, the count variable will be reset to '0'.

35. Give a name to your program, save it, and then compile it.

36. Now, the program is ready to burn on the RAK.

Scan QR code to view output

Exercise

A. Tick () the Correct Option.

1 Which of the following sensors has been used in the experiment?

a  Touch Sensor b  IR Sensor

c  Ultrasonic Sensor d  Sound Sensor

2 Which of the following blocks is used to print data on the defined row of the LED display?

a b c d  None of these

3 How do you stop a moving bot?

a  By selecting the "Pause" option from the drop-down menu of the "Move Motor at" block.

b  By selecting the "Stop" option from the drop-down menu of the "Move Motor at" block.

c  By selecting the "Stop" block from the "Motor" category.

d  By selecting the "Pause" block from the "Motor" category.

B. Answer the Following.

1 What is the use of the touch sensor in the experiment?

2 When does the message "Lifting" appear on the LED while conducting the experiment?

C. Apply Your Learning.

1 What is the primary function of a simple crane bot?

2 At a construction site, which machine is used to lift heavy materials like bricks and steel beams?

Experiment 4: Ball Shooter 5

Objective

To learn about the launching mechanism in various gear-using ball shooters by programming those robots.

Let’s Build

1 Connect three 7.5" L-Channels (two of them must be parallel to each other, while the third should be placed perpendicularly across the two parallel L-Channels). Use 12mm Bolts and K-Nuts as shown.

2 Connect the 7.5" Rectangle to one of the parallel L-Channels in the assembly using Nuts and Bolts

3 Connect the High Speed Motor to the 7.5" Rectangle using an Axle, an Axle Lock, and Bolts

4 Insert the 3.5" Axle in the Big Spur Gear and fix the connection using Axle Locks as shown.

5 Connect the Big Spur Gear in the assembly from the previous step to the Axle from step 3 using K-Nuts and Fillers as shown.

6 Connect the 3-Hole Connector to the 7.5" L-Beam using a Nut and Bolt.

7 Connect the previous assembly to the Axle of the High Speed Motor in the assembly from step 5.

8 Connect the Touch Sensor to the 7.5" Rectangle using Bolts and then connect the 7.5" Rectangle to the L-Channel using Nuts and Bolts. Also, insert the Axle (which is connected to the High Speed Motor and Big Spur Gear) into the 7.5" Rectangle as shown.

9 Connect the FULL 2.0 Brain to the 7.5" Rectangle in the assembly using Bolts. This will complete the assembly as shown.

1. Click on the Control category from the Blocks panel.

2. Drag the My Program block to the workspace to begin your program. The execution of all the blocks present inside this occurs step by step.

3. Drag the Repeat while block from the Loops category and drop it inside the My Program block to begin the infinite loop. The loop value is set to true by default.

4. Click on the Variables category.

5. Click on the Create variable button. A pop-up box appears asking you to enter a new variable name.

• Enter a suitable variable name like "touch_sensor ".

7. Then drag the Read Touch Sensor at block from the Sensor category and attach it to the set to block.  Let’s Code

• Click on the OK button. This will create a variable to store the data of the touch sensor value received from the sensor.

6. Drag the set to block from the Variables category and drop it inside the Repeat while block.

8. Set the value of the Read Touch Sensor at block to "Port5 (Advance)".

9. Drag the if block from the Control category and place it below the set to block.

10. Click on the settings icon of the if block. A pop-up box appears.

11. Drag the else block and place it below the if block in the pop-up box (refer to the image below).

12. Again, click on the settings icon to hide the pop-up box.

13. Drag the equal operator block from the Control category and attach it to the if block.

14. Select the ">" option from the drop-down of the equal operator block.

15. Drag the touch_sensor block from the Variables category and drop it in the left value box of the greater than operator block.

16. Drag the number block from the Math category and drop it in the right value box of the greater than operator block.

17. Type "400'' in place of "0" in the number block. If the value of the touch_sensor variable is greater than 400, i.e., the Touch Sensor senses the touch, and the blocks under the if block will be executed, otherwise the blocks under the else block will be executed.

18. Drag the Move Motor at block from the Motor category and drop it in the do part of the if block.

19. Configure the motor at Port4 (Advance) as anticlockwise by selecting the Anticlockwise option from the drop-down.

20. Select the speed of the motor as High from the Speed drop-down.

21. Drag the Time block from the Control category and drop it below the Move Motor at block. Type "500" in the value box of the Time block.

22. Similarly, drag another Move Motor at block and drop it below the Time block.

23. Select the Port4 (Advance) as clockwise by selecting the Clockwise option from the drop-down.

24. Select the speed of the motor as Medium from the Speed drop-down.

25. Drag the Time block from the Control category and drop it below the Move Motor at block. Type "500" in the value box of the Time block.

26. Now, drag the Move Motor at block and drop it inside the else block. Configure the motor at Port4 (Advance) to stop by selecting the "Stop" option from the drop-down.

27. Give a name to your program, save and then compile it.

28. Now the program is ready to burn on the RAK.

Note: The RAK should be connected to your computer through a Bluetooth or USB cable for the experiment to run.

Scan QR code to view output

Exercise

A. Tick () the Correct Option.

1 Which of the following sensors has been used in this experiment?

a  Touch Sensor b  Sound Sensor

c  IR Sensor d  Colour Sensor

2 Which block is used to create a continuous loop in this program?

a  My Program b  Repeat while c  If d  Set to

3 In the experiment, the motor direction is set to which option for launching the ball?

a  Forward

c  Left

B. Fill in the Blanks.

b  Backward

d  Right

1 The program starts by dragging the 'My Program' block from the category.

2 The bot shoots the ball once the value of the touch sensor variable becomes more than

3 The 'touch sensor ' variable stores data from the touch sensor set to Port .

4 The motor is configured to stop in the block if the touch sensor value is less than 400.

C. Apply Your Learning.

1 Does changing the motor speed setting affect the distance or force of the ball shot by the launcher? Explain.

2 Explain why a continuous loop is important in the ball-shooting program. How does it help the launcher mechanism?

Experiment 5: Simple Crane Using AI 6

Objective

To demonstrate how a simple crane functions as a lifting mechanism, where objects are lifted using a hook attached to a gear combination driven by a high-torque motor, and controlled through AI.

Background

Artificial Intelligence (AI)

Artificial Intelligence or AI, is the field of computer science that deals with the study of the principles, concepts, and technology for building machines that can think, act, and learn like humans. Machines possessing AI should be able to mimic human traits like making decisions, recognising patterns, predicting outcomes based on certain actions, learning, and improving on their own.

Natural Language Processing (NLP)

NLP is a domain of AI that enables computers to understand human language and generate appropriate responses when we interact with them. It allows computers to talk to us in a way that feels natural to us. Popular examples of NLP applications include Google Assistant, Siri, Alexa, Google Translate, etc.

Computer Vision

Computer Vision is a domain of AI which uses cameras to see and understand visual information.

Things Around Us

Some of the real-life examples of NLP are:

1. Virtual Assistants
2. Language Translation Apps

1. Face Recognition in Smartphones 2. Self-driving Cars

Simple Crane AI: Using Speech Recognition Mode

In this experiment, the use of NLP in the RAK bot includes:

• Recognising spoken commands such as "lift", "drop", "forward", "back", "left", and "right".

• Converting spoken commands into actions that the RAK can execute.

• Detecting user input that is not clear and prompting the user to repeat the commands.

Let’s Code

1. Click on the Control category from the Blocks panel.

2. Drag the My Program block to the workspace to begin your program. The execution of all the blocks present inside this will occur step by step.

3. Drag the repeat while block from the Loops category and drop it inside the My Program block to begin the infinite loop. The loop value is set to true by default.

4. Click on the Variables category.

5. Click on the Create variable button. A pop-up box appears asking you to enter a new variable name.

• Enter a suitable variable name like "speech".

• Click on the OK button.

6. Drag the set to block from the Variables category and drop it inside the repeat while block.

7. Then drag the get recognised speech block from the Speech Recognition category and attach it to the set to block.

8. Drag the if block from the Control category and place it below the set to block.

9. Click on the settings icon of the if block. A pop-up box appears.

10. Drag five else if blocks and place them below the if block in the pop-up box (refer to the image below).

11. Click on the settings icon again to hide the pop-up box.

12. Drag the includes block from the Text category and attach it to the if block.

13. Drag the speech block from the Variables category and drop it in the left text box of the includes block.

14. Type "lift" in the right text box of the includes block.

15. Drag the Print Data block from the Display category and drop it in the do part of the if block.

16. Drag the Text Box block from the Text category and drop it in the empty part of the Print Data block. In the Text Box block, type "Lifting".

17. Drag the Move Motor at block from the Motor category and drop it below the Print Data block.

18. Configure the motor at Port2 (Advance) as anticlockwise by selecting the Anticlockwise option from the drop-down.

19. Select the speed of the motor as Medium from the Speed drop-down.

20. Drag the Time block from the Control category and drop it below the Move Motor at block.

21. Type "2000" in the value box of the Time block.

22. Similarly, set the conditions for "drop" in the first else if block as shown in the figure below.

23. Similarly, set the conditions for "forward" in the second else if block as shown in the figure below.

24. Similarly, set the conditions for "back" in the third else if block as shown in the figure below.

25. Similarly, set the conditions for "right" in the fourth else if block as shown in the figure below.

26. Similarly, set conditions for "left" in the fifth else if block as shown in the figure below.

27. Give your program a name, save it and then compile it.

28. Now the program is ready to burn on the RAK.

Note: The RAK should be connected to your computer through a Bluetooth or USB cable for the experiment to run.

29. Click on the Run button in the AI window.

30. Allow the system to use your microphone to hear your commands.

31. Click on the microphone button present in the AI window.

32. Give any command (lift, drop, forward, back, left or right). Here, the AI detects the voice as "forward".

33. Click on the microphone button again and observe the output.

Simple Crane AI: Using Camera Capture Mode

In this experiment, computer vision is used to recognise hand gestures through the use of camera.

• The AI model is trained to detect specific hand poses, such as palm, fist, one finger, two fingers, three fingers, four fingers, and no gesture.

• Once trained, the model can identify these gestures in real-time.

• Each gesture then triggers specific actions within the game, such as lifting, dropping, moving forward or backward, turning right or left, and stopping. This allows players to control the bot with their hand movements.

Instructions

Before we start writing the code, let us train our AI Model. Follow the given steps:

1. Allow the system to use your camera.

2. Click on the Configure AI Model button in the AI Window on the right of your screen.

3. Choose your model by selecting Handpose from the Create Your Model pop-up window.

4. Add a name for your model and click on the Save button. You can also skip it.

5. Now, add the label name as 'Palm' and click on the Save button.

6. Click on the Start Recording button and show your palm up to 60 frames on the camera.

7. Now, click on the Plus sign on the top-left corner and add a name for Label 2. Here, the name of Label 2 is "Fist". Then, click on the Save button.

8. Similarly, record different fist postures up to 60 frames on the camera.

9. Similarly, add other labels such as 1 finger, 2 finger, 3 finger, and 4 finger.

10. Now, click on the Train Model button to train the AI about the recorded handposes. It will take a few minutes.

11. Add an appropriate model name and save it.

12. Test your model to check whether the AI is able to recognise the palm, fist, and different number of fingers postures correctly.

13. Now, click on the Download button.

14. You are now ready to write your code.

Let’s Code

1. Click on the Control category from the Blocks panel.

2. Drag the My Program block to the workspace to begin your program. The execution of all the blocks present inside this occurs step by step.

3. Drag the repeat while block from the Loops category and drop it inside the My Program block to begin the infinite loop. The loop value is set to true by default.

4. Drag the if block from the Control category and place it inside the repeat while block.

5. Click on the settings icon of the if block. A pop-up box appears.

6. Drag six else if blocks and place them below the if block in the pop-up box (refer to the image below).

7. Click on the settings icon again to hide the pop-up box.

8. Define the condition for the if block by dragging the equal operator block from the Control category and attaching it to the if block.

9. Drag the get detected AI label block from the AI category and drop it in the left value box of the equal operator block.

10. Drag the Palm block from the AI category and drop it in the right value box of the equal operator block.

11. Drag the Print Data block from the Display category and drop it in the do part of the if block.

12. Drag the Text Box block from the Text category and drop it in the empty part of the Print Data block. In the Text Box block, type "Lifting".

13. Drag the Move Motor at block from the Motor category and drop it below the Print Data block.

14. Configure the motor at Port2 (Advance) as anticlockwise by selecting the Anticlockwise option from the drop-down menu.

15. Select the speed of the motor as Medium from the Speed drop-down menu.

16. Similarly, set conditions for "Fist" in the first else if block as shown in the figure below. (For Fist block, you need to select the "Fist" option from the drop-down menu of the Palm block.)

17. Similarly, set conditions for "1 finger" in the second else if block as shown in the figure below.

18. Similarly, set conditions for "2 finger" in the third else if block as shown in the figure below.

19. Similarly, set conditions for "3 finger" in the fourth else if block as shown in the figure below.

20. Similarly, set conditions for "4 finger" in the fifth else if block as shown in the figure below.

21. Similarly, set conditions for "None" in the sixth else if block as shown in the figure below.

22. Give a name to your program, save it, and then compile it.

23. Now the program is ready to burn on the RAK.

Note: The RAK should be connected to your computer through a Bluetooth or USB cable for the experiment to run.

24. Click on the Run button on the AI window.

25. Show any hand pose (Palm, Fist, 1 Finger, 2 Finger, 3 Finger, 4 Finger or no pose) on the camera.

26. Observe the output.

Scan QR code to view output

A. Tick () the Correct Option.

1 Which block is used to create a continuous loop?

a  My Program b  repeat while c  If d  set to

2 In the experiment, the motor is set to turn in which direction to lift the crane hook? a  Clockwise b  Anticlockwise

c  Both directions d  Stop

3 In the experiment, what gesture is used to move the bot in the left direction?

a  Fist b  Palm

c  4 Finger d  None of these

B. Fill in the Blanks.

1 The program begins by dragging the block.

2 In the experiment, the variable "speech" stores the command received from recognition.

3 The crane will when the AI detects no hand pose.

C. Apply Your Learning.

1 Describe how voice commands can make controlling the crane more efficient than using manual controls.

2 If the motor speed is increased when lifting the crane, how could this affect the crane’s performance? Consider stability and control.

Maker Board

Exploring the Hardware Kit 1

About Maker Board

Maker Board is an easy-to-use electronic platform that helps you to make innovative projects. It consists of a 5×5 RGB LED matrix, a buzzer, four push buttons and six GPIO pins.

You can use your creative ideas using the Maker Board by controlling its electronic sensors and modules. You can make and play interactive games using the LED matrix and the push buttons. You can make a piano, a snake game, a smart band, and many more such things.

Components of the Hardware Kit

The Maker Board robotics kit contains the following components:

The Maker Board can be programmed using the Maker Studio coding interface, an easy-to-use Graphical User Interface (GUI) block-based coding platform.

1. Maker Board 2. IR Sensor 3. Servo Motor 4. LEDs
5. Jumper Cable 6. Batteries 7. LDR Sensor
8. Rain Sensor

Detailed Description of the Components

1. GPIO Pads

There are 4 Pulse Width Modulation (PWM) pins and 2 Analog to Digital Converter (ADC) pins, which make a total of 6 General Purpose Input Output (GPIO) pins to interface with analog and digital sensors, LEDs, Motors, etc., using jumper cables and alligator clips.

2. Power Pins

1 VCC pin—This pin outputs a regulated voltage of 3.3V.

2 GND pins—Power Output (0V).

1 VIN pin—The input voltage to the Maker Board when it is using an external power source.

3. Programming LED Matrix

An LED matrix is a grid of addressable Red, Green, and Blue (RGB) LEDs arranged in rows and columns. In this, a total of 25 addressable RGB LEDs are used, which can be controlled individually. An LED matrix can be used to display animations or scroll text, numbers, patterns, etc. It can also be used to make different types of 8-bit games.

4. Push Buttons

There are 4 on-board push buttons named A, S, W, and D to perform various operations like activate, deactivate or move the blinking light of the LED in different directions.

5. Buzzer

The buzzer is used to make different types of sounds at distinct frequencies and at different beats per minute.

6. Reset Button

The reset button is used to restart any program loaded in the Maker Board.

7. Bluetooth Module (HC-05)

The Bluetooth module gets you started with the possibilities of IoT and enables wireless controlling of various equipment connected to the Maker Board.

IoT stands for Internet of Things which refers to a network of interconnected devices embedded with sensors and software, enabling them to collect, exchange data, and make autonomous decisions.

8. Standoff Holes

These holes are present to ensure that the Maker Board can be safely used on electrically conductive surfaces.

About Maker Studio Coding Interface

The Maker Studio coding interface acts as an integrated development environment that allows you to write code for all of your projects. This code is then loaded into the Maker Board.

The Maker Studio coding interface consists of five major components:

1. A workspace area to drag blocks for the code you want to create.

2. A blocks panel, which contains all the blocks required to make your code.

3. The Share Code option in the File drop-down menu generates a shareable link for the project.

4. Buttons to save, compile, and burn your code.

5. The Simulator Window to see the output.

Burning Your Code into Maker Board Hardware

Burning means loading your code into the Maker Board hardware. This process, mainly, has the following phases:

Arrange the blocks to create the code Save the code

Compile the code Burn the code

In case of error, recheck the code.

Experiment 1: Flag Book 2

Objective

Let’s make a Flag Book to understand the concept of animation.

Background

Animation

Animation is a method in which figures are manipulated to appear as moving images. In traditional animation, images are drawn or painted by hand on transparent celluloid sheets to be photographed and exhibited on film. Today, most animations are made with computer-generated imagery (CGI).

Things Around Us

Some of the real-life examples of flag books are:

Let’s Code

1. Click on the Control category from the Blocks panel.

2. Drag the My Program block to the workspace to begin your program. The execution of all the blocks present inside this occurs step by step.

Cartoons
Mobile games

3. Drag the repeat while block from the Loops category and drop it inside the My Program block.

4. Drag the show LEDS block from the Display category and drop it inside the repeat while loop block.

5. Select the colour from the Select color palette and click on squares of LED Matrix to change the colour, and set the Brightness to "100".

6. Drag the wait block from the Control category and drop it below the show LEDS block.

7. Type "1000" in the value box of the wait block. This will create a delay of 1 second in displaying the next step.

8. Drag two more show LEDS blocks and select different colour patterns on them.

9. Give the wait blocks accordingly to adjust the delay.

10. Drag the clear display block from the Display category and drop it below the wait block used above.

11. Thereafter, drag and drop another wait block and set its value to "1000".

12. Give a name to your program, save and then compile it.

13. Now the program is ready to burn on the Maker Board, and you can use your Flag Book.

Note: The Maker Board should be connected to your computer through a USB for the experiment to run.

Scan QR code to view output

A. Tick () the Correct Option.

1 Which category of blocks do you select to start building the program?

a  Variables b  Control

c  Loops d  Display

2 What is the purpose of the wait block in this program?

a  To change LED brightness b  To set a time delay between actions

c  To add colour to the LED d  To display text

3 What is the brightness level set to in the show LEDS block?

a  50 b  75

c  100 d  150

B. Answer the Following.

1 What do you mean by animation?

2 What is the purpose of the clear display block in the program?

C. Apply Your Learning.

1 Give any two real-life examples where you have seen animation.

2 How can you reduce the time between each colour showing up on the LED matrix?

Experiment 2: Blinking of LEDs 3

Objective

Let’s make a circuit to glow LEDs using different buttons.

Background

1. Circuit

• Electric circuits are paths for transmitting electric current or moving electricity.

• Such circuits allow electricity to be used to provide power to lights, appliances, and many other devices.

• Electricity can only flow around a complete circuit that has no gaps.

• Current is the flow of electrical charge through materials.

2. Parts of the Circuit

• There is a power supply (the battery).

• There should be no gaps anywhere, so that the electrical current can flow around the entire circuit.

• The wires connect the positive and the negative ends of the battery.

• Next, circuits need connectors. Connectors connect all the parts of the circuit and create the path or loop through which the electricity passes. Connectors are often made of wire or other metal.

• Another component is the load. This is the object being powered by the electricity in a circuit. It could be a light bulb, a TV, a fan, or any of the electronic gadgets we use every day.

Things Around Us

Some of the real-life examples are:

1. Digital sign boards

2. Road lamps

• Connect the P0 pin of the Maker Board with the longer leg of LED 1 with a resistor in between.

• Connect the GND pin of the Maker Board with the shorter leg of LED 1.

• Connect the P3 pin of the Maker Board with the longer leg of LED 2 with a resistor in between.

• Connect the GND pin of the Maker Board with the shorter leg of LED 2.

Let’s Code

1. Click on the Control category from the Blocks panel.

2. Drag the My Program block to the workspace to begin your program. The execution of all the blocks present inside this occurs step by step.

3. Drag the configure pin block from the Hardware category, and drop it inside the My Program block.

4. Select the P0 pin as Output

5. Now, drag and drop another configure pin block, and select the P3 pin as Output

6. Now, drag the repeat while block from the Loops category and drop it below the last configure pin block.

7. Now, drag the If button block from the Button category and drop it inside the repeat while block.

8. Set the value of the button to "W" from the drop-down.

9. Now, drag the show pattern block from the Display category and drop it inside the If button block.

10. Select any pattern of your choice for the LED Matrix from the drop-down.

11. Now, drag two output pin blocks from the Hardware category and drop them below the show pattern block.

12. For the first output pin block, select "P0" as "High", so that LED 1 is turned on, and for the second block, select "P3" as "Low", so that LED 2 is turned off.

13. Now, drag and drop another If button block and set the value to "A".

14. Now, drag another show pattern block and drop it inside the last If button block.

15. Select any pattern of your choice different from the one selected earlier.

16. Now, drag two output pin blocks and drop them below the show pattern block.

17. For the first output pin block, select "P0" as "Low", so that LED 1 is turned off, and for the second output pin block, select "P3" as "High", so that LED 2 is turned on.

18. Give a name to your program, save it, and then compile it.

19. Now, the program is ready to burn on the Maker Board, and you can use your blinking LED.

Note: The Maker Board should be connected to your computer through a USB for the experiment to run.

Scan QR code to view output

A. Tick () the Correct Option.

1 What is the role of a connector in a circuit?

a  Provides power to the load b  Creates the path for electricity to flow

c  Controls the speed of current

d  Acts as a load in the circuit

2 Which pin is configured to turn on LED 2 in the Maker Board setup?

a  P0

c  P3

b  GND

d  USB

3 What is the purpose of the "Repeat while" block in the program?

a  To stop the LEDs from blinking

b  To ensure continuous execution of the LED blinking logic

c  To configure the Maker Board pins

d  To compile the program

B. Answer the Following.

1 List the essential parts of an electric circuit.

2 Explain how the Maker Board controls the blinking of two LEDs using button inputs.

C. Apply Your Learning.

2 Design a circuit where three LEDs glow sequentially based on three different button inputs. Describe the connections and logic required in the program.

2 Suggest two real-life applications where LED blinking systems can be utilised. Explain their significance.

Experiment 3: Rain Alarm 4

Objective

Let us make a project that uses a raindrop sensor to develop an automatic rain alarm to alert farmers.

Background

Sensors

• A sensor is a device that detects and responds to certain inputs from the physical environment. These inputs can include light, heat, motion, moisture, pressure, and other environmental factors.

• A water sensor brick is designed for detecting water. It can be used in various applications, such as sensing rainfall, monitoring water level, and detecting liquid leakage.

• This type of sensor can detect the presence, level, volume, or absence of water.

Things Around Us

Some of the real-life examples:

Circuit

• Connect the jumper cable wires to the water sensor.

• Connect the VCC of the water sensor to the VCC of the Maker Board.

• Connect the GND of the water sensor to the GND of the Maker Board.

1. Automatic car wipers
2. Irrigation network

• Connect the D0 of the water sensor to the P0 of the Maker Board.

• Connect the battery connector and the battery, and keep it ready.

• Connect the positive terminal to Vin.

• Connect the negative terminal to Gnd.

1. Click on the Control category from the Blocks panel.

2. Drag the My Program block to the workspace to begin your program. The execution of all the blocks present inside this occurs step by step.

3. Now, drag the configure pin block from the Hardware category and drop it inside the My Program block.

4. Select P0 pin as Input.

5. Drag the repeat while block from the Loops category and drop it below the configure pin block. This block is set to true by default. The blocks present inside the repeat while block will be executed sequentially again and again until the condition is true. Once the condition becomes false, the blocks inside this block will stop working. Let’s Code

6.

Drag the if block from the Control category.

7. Attach the equal operator block to the right of the if block.

8. Drag the read status block from the Hardware category and drop it in the left part of the equal operator block.

9. Drag the number block from the Math category and attach it to the right part of the equal operator block.

10. Drag the play tone of frequency block from the Sound category and drop it as shown in the figure below. This will play a sound.

11. Give a name to your program, save it, and then compile it.

12. Now, the program is ready to burn on the Maker Board.

Note: The Maker Board should be connected to your computer through a USB for the experiment to run.

A. Tick () the Correct Option.

1 What is the primary function of a rain drop sensor in this project?

a  Detecting motion b  Measuring light intensity

c  Detecting water presence d  Monitoring temperature

2 Which pin of the Maker Board is the rain drop sensor connected to?

a  P0 b  P1

c  VCC d  GND

3 Which category contains the block used to play a sound?

a  Loops b  Sound

c  Hardware d  Control

B. Answer the Following.

1 What is the role of the play tone of frequency block in the code?

2 How does the equal operator block help in this project?

C. Apply Your Learning.

1 How can a rain alarm system help farmers during monsoon season?

2 What other applications can you think of for a water sensor besides rain detection?

Experiment 4: Automatic Night Lamp

Objective

Let’s make a night lamp to learn the concept of LDR Sensor.

Background

1. LDR

Light-dependent resistors, LDRs or photoresistors are electronic components that are often used in electronic circuit designs where it is necessary to detect the presence or the level of light.

• LDRs are very different from other forms of resistors like carbon film resistors, metal oxide film resistors, metal film resistors, and the like that are widely used in other electronic designs. They are specifically designed for their light sensitivity and the change in resistance they cause.

• These electronic components can be described by a variety of names from light-dependent resistor, LDR, photoresistor, or even photocell or photoconductor.

2. If Block

• Conditional blocks have conditions and the program’s flow is based on whether the condition is true or not.

• To apply conditions in code, use the if block. The if block has else if and else blocks.

• If the condition given in the if block is true, then the set of code is executed; otherwise, the code given in else if or else block is executed.

Things Around Us

Some of the real-life examples are:

1. Solar street lighting

2. Burglar alarm circuit

• Connect the P0 of the Maker Board with the OUT pin of the LDR sensor.

• Connect the GND of the Maker Board with the GND pin of the LDR sensor.

• Connect the VCC of the Maker Board with the VCC pin of the LDR sensor.

Let’s Code

1. Click on the Control category from the Blocks panel.

2. Drag the My Program block to the workspace to begin your program. The execution of all the blocks present inside this occurs step by step.

3. Drag the configure pin block from the Hardware category and drop it inside the My Program block. The P0 pin for the Output is selected by default.

4. Drag the repeat while block from the Loops category and drop it below the configure pin block.

5. Create a variable named "lightSensorValue".

6. Now, drag the set to block from the Variables category and drop it inside the repeat while block.

7. Drag the read status block from the Hardware category and attach it to the right of the set to block. Define the set to block with the pin "P0" of the read status block.

8. Drag the if block from the Control category and drop it below the set to block.

9. Click on the settings icon of the if block. A pop-up box appears.

10. Drag the else condition to the pop-up box, and drop it below the if block. The else condition is executed when the condition is false.

11. Drag the equal operator block from the Control category and attach it to the right of the if block.

12. Now, insert the "lightSensorValue" variable block in the left part of the equal operator block.

13. Drag the block from the Math category and drop it to the right part of the equal operator block.

14. Drag the clear display block from the Display category and drop it inside the do condition block.

15. Drag the show LEDS block from the Display category and drop it inside the else condition.

16. Assign any pattern of your choice in the LED Matrix.

17. Give a name to your program, save it, and then compile it.

18. Now, the program is ready to burn on the Maker Board, and you can use the automatic night lamp.

Note: The Maker Board should be connected to your computer through a USB for the experiment to run.

Scan QR code to view output

A. Tick () the Correct Option.

1 Which of the following sensors has been used in the experiment?

a  Touch Sensor b  Sound Sensor

c  IR Sensor d  LDR Sensor

2 What happens in the 'else' condition of the program?

a  The display is cleared

c  The sensor stops working

b  The LED matrix displays a pattern

d  The Maker Board restarts

3 Which of the following is an application of the automatic night lamp created in the experiment?

a  Solar Street lighting

b  Burglar alarm circuit

c  Both a and b d  None of the above

B. Fill in the Blanks.

1 The "configure pin" block is available in the category of the blocks.

2 The block is used to check conditions and execute actions based on them.

3 The "clear display" block removes any pattern shown on the .

4 The variable named is used to store the value read from the LDR sensor.

C. Apply Your Learning.

1 What would happen if the variable light Sensor Value is not defined?

2 Why is an LDR considered unique compared to other resistors?

6 Experiment 5: Wandering Sprite 2

Objective

Let us make a game with two sprites—a food and a player sprite on the display of the Maker Board. In this game, the player sprite will try to catch the food sprite within a specified number of attempts. If successful, you win, but if the player sprite touches one of the edges of the maze, you lose.

Background

1. Sprites

• A sprite is a two-dimensional bitmap that is part of a larger scene.

• Sprites can be static images or animated ones.

• Sprites have location in the x and y coordinates.

• The blocks of the Sprite category are used to perform various operations related to LEDs. A sprite is an element which helps to develop independent animated images, text, etc., that can then be combined in larger animation or patterns. In this category, there are blocks that help to perform different operations using these sprites.

2. Sprite Movement

• A sprite, which is basically a character, is displayed as light on the Maker Board.

• You can set its colours and brightness.

• You can make it move in steps, change its direction, and set its position through x and y points.

Things Around Us

Some

of the real-life examples are:

Video games like Super Mario, Pac-Man, etc.

Let’s Code

1. Click on the Control category from the Blocks panel.

2. Drag the My Program block to begin your program. The execution of all the blocks present inside this occurs step by step.

3. Click on the Variables category.

4. Click on the Create variable button. A pop-up box appears asking you to enter a new variable name.

• Enter a suitable variable name, let’s say "score".

• Click on the OK button.

5. Drag the set to block from the Variables category and drop it inside the My Program block.

6. Click on the Math category and attach the number block with the set to block. The number block is set to '0' by default.

7. Click on the Sprite category.

8. Click on the Create Sprite button to create a sprite variable.

9. A pop-up box appears asking you to enter a new variable name.

• Enter a suitable sprite name, let’s say 'player'.

• Click on the OK button.

10. Drag the draw sprite block from the Sprite category and drop it below the set to block.

11. Type the values of the x and y coordinates as 2 and 2, respectively. You can set the position of the player sprite through x and y coordinates. You can type any suitable value for these coordinates.

12. Choose the color for the sprite and set the brightness to '100'.

Note: The sprite faces in the right direction by default.

13. Similarly, create another sprite variable 'food' and drag and drop the draw sprite block below the previous draw sprite block.

14. Choose the color for the food sprite and set the brightness to '100'.

15. Drag two pick random number from blocks from the Math category and drop one block in the x text box and the other in the y text box of the second draw sprite block.

16. Write '1' and '3' for the random numbers in both the pick random number from blocks. You can choose any suitable values for the random numbers for the blocks. The food sprite will randomly appear at these x and y coordinates.

17. Drag the Repeat while block from the Loops category and drop it below the last draw sprite block. The Repeat while block is set to true by default.

18. Drag the If button block from the Button category and drop it inside the repeat while block to set the condition for button 'W' to be pressed.

19. To ensure that the sprite moves up when the 'W' key is pressed, follow the given steps:

• Drag the turn sprite block from the Sprite category and drop it inside the If button block. Select 'player' from the drop-down menu of the block.

• Turn the player sprite left by selecting 'left' for the direction and '90' for the degrees in the drop-down.

• Drag and drop the move sprite block below the turn sprite block. Select 'player' from the drop-down menu of the move sprite block. The move sprite block is set to '1' step, by default. The block will move the player sprite by '1' step.

• Drag and drop the turn sprite block below the move sprite block. Select 'player' from the drop-down menu of the block.

• Turn the sprite right by selecting 'right' for the direction and '90' for the degrees in the drop-down menu.

20. Drag another If button block and drop it below the previous If button block. Select 'A' from the drop down of the block to set the condition for button 'A' to be pressed.

21. Drag and drop the move sprite block inside the If button block. Select 'player' from the drop-down menu of the block. Type '-1' for the steps in the text box of the block. The block will move the player sprite by '-1' step.

22. Similarly, set actions based on different events (pressing keys S or D) by using the If button blocks. It will allow the user to move downwards and in the right direction.

23. Drag the if block from the Control category and place it below the If button block.

24. Drag the touching Sprite block from the Sprite category and attach it with the if block. Select the 'player' option from the first drop-down and the 'food' option from the second drop-down of the touching Sprite block.

25. Drag the set sprite location block from the Sprite category and drop it in the do part of the if block. Select the 'food' option from the drop-down of the set sprite location block.

26. Drag two pick random number from blocks from the Math category and drop one block in the x text box and the other in the y text box of the set sprite location block.

27. Write '1' and '3' for the random numbers in both the pick random number from blocks. You can choose any suitable values for the random numbers for the blocks. The food sprite will randomly appear at these x and y coordinates.

28. Drag the set to block from the Variables category and drop it below the set sprite location block.

29. Drag the add operator block from the Math category and attach it with the set to block.

30. In the left text box of the add operator block, drop the score variable block from the Variables category.

31. Drag another (second) if block from the Control category and drop it below the previous if block.

32. Drag the equal operator block from the Control category and attach it with the if block. Select the '≥' option from the drop-down menu of the equal operator block.

33. Drag and drop the score variable block in the left part of the greater than equal to operator block.

34. In the right part of the greater than equal to operator block, drag and drop the number block from the Math category. Type '10' in the text box of the number block. You can choose any suitable value for the score variable as your winning score.

35. Drag the show scrolling text block from the Display category and drop it to the right of the do block.

36. Type "YOU WON" for the text part of the block, set the colour to yellow from the color palette and set the brightness to '100'. If the score variable is greater than or equal to 10, a scrolling text 'YOU WON' will be displayed.

37. Drag the show animation block from the Display category and drop it below the show scrolling text block. Select the 'Game Over' option from the drop-down menu of the show animation block.

38. Drag another (third) if block from the Control category and drop it below the second if block.

39. Drag the and operator block from the Control category and attach it with the if block. Select the 'or' option from the drop-down menu of the and operator block.

40. Drag two more and operator blocks and drop one and block to the left of the or block and another to its right.

41. Select the 'or' option from the drop-down menu of both the and operator blocks.

42. Drag four touching edge blocks from the Sprite category and drop these blocks in the left and right parts of the or operator blocks, as shown.

43. Select the 'player' sprite option from the left drop-down menu of the four touching edge blocks. Select 'top', 'bottom', 'left', and 'right' options from the right drop-down menu of the four blocks.

44. Drag the show scrolling text block from the Display category and drop it to the right of the do block.

45. Type 'YOU LOST' for the text part of the block, set the colour to red from the color palette and set the brightness to '100'. If the player sprite touches the top, bottom, left or right edges, then a scrolling text 'YOU LOST' will be displayed.

46. Drag the show animation block from the Display category and drop it below the show scrolling text block. Select the 'Game Over' option from the drop-down menu of the show animation block.

47. Give your program a name, save it, and then compile it.

48. Now the program is ready to burn on the Maker Board, and you can see the output on the digital display.

Scan QR code to view output

A. Tick () the Correct Option.

1 What is the primary goal of the experiment?

a  To create as many sprites as possible.

b  To catch the food sprite within a limited number of attempts.

c  To display random animations on the Maker Board.

d  To move the player sprite without touching the maze edges.

2 What causes the player to lose the game?

a The player sprite catches the food sprite.

c The player sprite touches the edges of the maze.

b The food sprite touches the edges of the maze.

d  None of these

3 What can a sprite represent in a game created using the 'Sprite' category blocks?

a Only static background images.

c A static element that cannot move or change.

B. Answer the Following.

1 Explain the 'draw sprite' block.

b Independent animated elements like images or text.

d  None of these

2 When does the animated text "YOU WON" appear on the Maker Board?

C. Apply Your Learning.

1 Name any two games where a sprite moves around to catch something while avoiding obstacles.

2 What other features could you add to make the game more engaging? (For example, you could introduce two food sprites instead of one.)

Experiment 6: Manual Boom Barrier 7

Objective

Let’s make a boom barrier using a servo motor.

Background

1. Boom Barrier

A boom barrier is like a big arm that goes up and down to control the traffic. Have you ever seen those long arms at the entrance of a parking lot or toll booth? That is called a boom barrier.

The boom barrier is there to make sure cars go in and out in an organised way. When the barrier is down, it means the cars need to stop and wait. It’s like a red light for the cars. But when the barrier goes up, it’s like a green light, and the cars can pass through.

2. Servo Motor

The servo motor is a special type of motor having a shaft that can move to a specific position and at a specific speed based on the received input. It is used in control applications and robotics.

The servo motor has three main parts: a motor, a sensor, and a controller.

The motor provides the mechanical power to move or rotate the shaft.

The sensors measure the position and the speed of the shaft.

The controller works like the brain of the servo motor. It tells the motor how much to move and in which direction.

Things Around Us

Some real-life examples of servo motors are:

1. Boom Barrier
2. Automated drones

• Connect the P0 of the Maker Board with the orange wire of the Servo motor.

• Connect the GND of the Maker Board with the brown wire of the Servo motor.

• Connect the positive terminal of the battery with the red wire of the Servo motor.

• Connect the negative terminal of the battery with the GND of the Maker Board.

Let’s Code

1. Click on the Control category from the Blocks panel.

2. Drag and drop the My Program block to begin your program. The execution of all the blocks present inside this occurs step by step.

3. Drag and drop the repeat while block from the Loops category.

4. Drag the If button block and select the W key from the Button category, and use it inside the repeat while block.

5. Now, add the move servo PWM pin block from the Hardware category in the If button block and set the P0 value to 90.

6. Drag the second If button block and use it inside the repeat while block to set the condition for the button A to be pressed.

7. Now, add the move servo PWM pin block in the If button block and set the P0 value at 0.

8. Now the program is ready to burn on the Maker Board, and you can use your manual boom barrier.

Note: The Maker Board should be connected to a power source through a USB for the experiment to run.

Scan QR code to view output

A. Tick () the Correct Option.

1 What is the main function of a boom barrier?

a  To guide pedestrians

c  To display traffic rules

b To control vehicle traffic at entry and exit points

d  To store car parking tickets

2 What component of a servo motor acts like its brain, directing movements?

a  Motor

c  Controller

b  Shaft

d  Sensor

3 Which pin of the Maker Board is connected to the servo motor’s orange wire?

a  GND

b  P3

c  P0 d  3V

B. Answer the Following.

1 Explain how a servo motor works. What are its main components?

2 What does a boom barrier indicate when it is down or up?

C. Apply Your Learning.

1 Create a real-life scenario where a manual boom barrier controlled by a servo motor is essential. Describe how it improves safety and efficiency.

2 Modify the program to add an additional button (e.g., key "D") that sets the boom barrier to a 45-degree angle. What will you need to change? Write down the steps.

8 Experiment 7: Manual Boom Barrier Using AI

Objective

To make a manual boom barrier to understand the concept of IR sensors and AI.

Background

Artificial Intelligence (AI)

Artificial Intelligence or AI, is the field of computer science that deals with the study of the principles, concepts, and technology for building machines that can think, act, and learn like humans. Machines possessing AI should be able to mimic human traits like making decisions, recognising patterns, predicting outcomes based on certain actions, learning, and improving on their own.

Natural Language Processing (NLP)

NLP is a domain of AI that enables computers to understand human language and generate appropriate responses when we interact with them. It allows computers to talk to us in a way that feels natural to us. Popular examples of NLP applications include Google Assistant, Siri, Alexa, and Google Translate.

Computer Vision

Computer Vision is a domain of AI which uses cameras to see and understand visual information.

Around

Some of the real-life examples of NLP are:

1. Virtual Assistants

Language Translation Apps

Some of the real-life examples of computer vision are:

1. Face Recognition in Smartphones 2. Self-driving Cars

Manual Boom

Barrier:

Using Speech Recognition Mode

In this experiment, the use of NLP in the Maker Board includes:

• Recognising spoken commands such as "up" or "down".

• Converting spoken commands into actions that the Maker Board can execute.

• Detecting user input that is not clear and prompting the user to repeat commands.

Let’s Code

1. Click on the Control category from the Blocks panel.

2. Drag the My Program block to the workspace to begin your program. The execution of all the blocks present inside will occur step by step.

3. Drag the repeat while block from the Loops category and drop it inside the My Program block to begin the infinite loop. The loop value is set to true by default.

4. Click on the Variables category.

5. Click on the Create variable button. A pop-up box appears asking you to enter a new variable name.

• Enter a suitable variable name like "speech".

• Click on the OK button.

6. Drag the set to block from the Variables category and drop it inside the repeat while block.

7. Then drag the get recognised speech block from the Speech Recognition category and attach it to the set to block.

8. Drag the if block from the Control category and place it below the set to block.

9. Click on the settings icon of the if block. A pop-up box appears.

10. Drag the else if block and place it below the if block in the pop-up box (refer to the image below).

11. Click on the settings icon again to hide the pop-up box.

12. Drag the includes block from the Text category and attach it to the if block.

13. Drag the speech block from the Variables category and drop it in the left text box of the includes block.

Type "up" in the right text box of the includes block.

15. Drag the move servo PWM pin block from the Hardware category and drop it in the do part of the if block.

16. Similarly, set the conditions for "down" in the else if block as shown in the figure below.

17. Give your program a name, save it and then compile it.

18. Now the program is ready to burn on the Maker Board.

Note: The Maker Board should be connected to your computer through a Bluetooth or USB cable for the experiment to run.

19. Click on the Run button on the AI window.

20. Allow the system to use your microphone to hear your commands.

21. Click on the microphone button in the AI window.

22. Give any command ("up" or "down"). Here, the AI detects the voice as "up".

23. Again, click on the microphone button and observe the output on the Maker Board.

Manual Boom Barrier: Using Camera Capture Mode

In this experiment, computer vision is used to recognise hand gestures with the help of a camera.

• The AI model is trained to detect specific hand poses, such as palm and fist.

• Once trained, the model can identify these gestures in real-time.

Instructions

Before we start writing the code, let us train our AI Model. Follow the given steps:

1. Allow the system to use your camera.

2. Click on the Configure AI Model in the AI Window on the right of your screen.

3. Choose your model by selecting Handpose from the Create Your Model pop-up window

4. Add a name for your model and save it. You can also skip it.

5. Now, add the label name as ‘Palm’ and click on the Save button.

6. Click on the Start Recording button and show your palm up to 60 frames on the camera.

7. Now, click on the Plus sign on the top-left corner and add a name for Label 2. Here, the name of Label 2 is ‘Fist’. Then, click on the Save button.

8. Similarly, show your fist on the camera and record different fist postures.

9. Now, click on the Train Model button to train the AI about the recorded hand poses. It will take a few minutes.

10. Add an appropriate model name and save it.

11. Test your model to check whether the AI is able to recognise the hand poses correctly.

12. Now, click on the Download button.

13. You are now ready to write your code.

1. Click on the Control category from the Blocks panel.

2. Drag the My Program block to the workspace to begin your program. The execution of all the blocks present inside this will occur step by step.

3. Drag the Repeat while block from the Loops category and drop it inside the My Program block to begin the infinite loop. The loop value is set to true by default.

4. Drag the if block from the Control category and place it inside the repeat while block.

5. Click on the settings icon of the if block. A pop-up box will appear.

6. Drag the else if block and place it below the if block in the pop-up box (refer to the image below).

7. Again, click on the settings icon to hide the pop-up box.

8. Define the condition for the if block using the equal to block from the Control category.

9. Drag the get detected AI label block from the Variables category and drop it in the left value box of the equal to block.

10. Drag the Palm block from the AI category and drop it inside the right value box.

11. Drag the move servo PWM pin block from the Hardware category and drop it inside the do part of the if block.

12. Define the condition for the else if block using the equal to block from the Control category.

13. Drag the get detected AI label block from the Variables category and drop it in the left value box of the equal to block.

14. Drag the Palm block from the AI category and drop it inside the right value box. Choose Fist from the drop-down menu of the Palm block

15. Drag the move servo PWM pin block from the Hardware category and drop it inside the do part of the else block.

16. Type "0" in the angle box value.

17. Give a name to your program, save it, and then compile it.

18. Now the program is ready to burn on the Maker Board.

Note: The Maker Board should be connected to a power source through a USB for the experiment to run.

Scan QR code to view output

A. Tick () the Correct Option.

1 What angle should the servo motor be set to for lowering the barrier? a  0 b  45 c  90 d  180

2 Which among the following categories has the  block? a  Sprite b  AI c  Hardware d  Console

3 In which of the following categories is the block ‘move servo PWM pin’ available? a  AI b  Hardware

c  Functions d  Sensors

B. Answer the Following.

1 What is the use of the block?

2 What is NLP?

C. Apply Your Learning.

1 Which do you think is better: a manual boom barrier without AI or an automated boom barrier with AI? Give reasons for your answer.

2 How might adding additional gestures, like "Wave," enhance the functionality of this boom barrier?

About the Book

This book introduces learners to the captivating realm of robotics, with a learner-friendly, motivating, and hands-on approach. It combines theoretical understanding with practice, through insightful examples of real-world applications, while promoting creativity and coding skills. Emphasising a project-based learning methodology, the book provides a series of projects, each with detailed instructions. These instructions can be effortlessly executed using the accompanying robotics hardware kit. The assembly and programming of the robotics systems are done through block-based coding, and simulation environments; accelerating the experiential learning journey of the learners.

Special Features

• Hands-on Experiments: Engaging experiments that allow students to build and test-run robots themselves.

• Detailed Coding Practice: Step-by-step coding instructions to program robots, making it easy for beginners to learn.

• Things Around Us: Each experiment connects robotics to real-world scenarios, showing how technology solves everyday problems.

• Comprehensive Background: Clear explanations of the concepts and the technology behind each experiment, helping students understand the "why" and the "how."

• Interactive Exercises: Exercises at the end of each experiment to reinforce learning and to challenge students to think critically.

About Uolo

Uolo partners with K-12 schools to provide technology-enabled learning programs. We believe that pedagogy and technology must come together to deliver scalable learning experiences that generate measurable outcomes. Uolo is trusted by over 15,000+ schools across India, Southeast Asia, and the Middle East.

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.