0% found this document useful (0 votes)
0 views

P5_3_robotics,_algorithm,_program_and_sequence,_conditional,_loop

The document provides an introduction to robotics, explaining key components such as sensors, controllers, and actuators, as well as tools like Micro:bit and Arduino for programming. It emphasizes the importance of algorithms, sequences, and conditional statements in programming robots to perform tasks. Additionally, it discusses the concept of variables in coding and includes various challenges to engage learners in understanding these concepts.

Uploaded by

bekako2404
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

P5_3_robotics,_algorithm,_program_and_sequence,_conditional,_loop

The document provides an introduction to robotics, explaining key components such as sensors, controllers, and actuators, as well as tools like Micro:bit and Arduino for programming. It emphasizes the importance of algorithms, sequences, and conditional statements in programming robots to perform tasks. Additionally, it discusses the concept of variables in coding and includes various challenges to engage learners in understanding these concepts.

Uploaded by

bekako2404
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 85

Computing

P5
Challenges:
1. How do you understand a robot?

2. Where have you seen the robots?

3. Do you think you should learn about robotics and physical


computing? Why or why not?

Humanoid

Non-humanoid

Robot arm
Introduction to Robotics
• Robotics is a branch of computer science and engineering
including hardware and software.
• Robots are machines having several parts including sensors,
controllers and actuators that help them do the work in various
ways when programmed.
• Hardware devices such as Micro:bit and Arduino can be used
to develop physical prototype projects that interact with the
real world.
Parts of a robot
1. Sensors: These could be any parts of a robot acting as eyes
and ears to get information from the surroundings or the input
data.

2. Controller: This is the brain of a robot that carries out the


instructions.

3. Actuators: Motor is an example of an actuator that moves the


robot's part such as arms or wheels.
Parts of a robot
What is a Micro:bit?
• Micro:bit is a small computer which takes input, processes the
input, and produces output.

• Open the browser and go to https://makecode.microbit.org.

Microsoft Makecode
Microsoft Makecode Interface
Micro:bit Connected to the Computer to download the program
What is Arduino?
• Arduino is similar to Micro:bit so it can be programmed to
take input, process the information and produce output to
interact with the real world.

Arduino Nano and Robot Car


Algorithm and program
Warm up!

1. When you have to solve a problem in real life, what is the first
step you do?
What did you learn in the last lesson?
• The micro:bit itself or any other physical devices are
considered hardware.

• In order to make use of hardware, software (otherwise known


as “code” or computer program) is essential.

• The software ‘tells’ the hardware what to do.

• The first step in creating a computer program is to create a list


of instructions that need to be carried out to complete a desired
task.

• This is called an algorithm.


1. Think about a plan or a set of instructions, like a map or a
recipe.

2. What are they for?

3. Why do you use them in your everyday life?

4. How do these plans or instructions help you in your daily life?


What is Algorithm?
• Algorithm is a plan or a series of step-by-step instructions for
the computer to solve a problem or perform a task.

• It can guide through the tasks whether it is big or small.

Think about making breakfast!


you will follow a series of steps
in a recipe to fry an egg.
4
Making a jam sandwich

18
Algorithms in real life

19
Algorithms in real life

20
• Organizing your books or planning your moves in a game are
examples of problem-solving in everyday life.
• It's clear that planning is an essential skill, whether you are
playing games or programming.

21
• In coding, algorithms contain steps to tackle a problem.
• Algorithms are not written in code. Instead, they are planned and
written in a simple language humans can understand during the
planning stage of program development.
If the algorithm is ready, this is turned into a program for the
computer to understand.

A program for microbit is created using a language called


Makecode.

If an algorithm is planned, any programming language can use


the algorithm and turn it into a program.
Challenges:

1. Plan an algorithm to tell a robot to wash a dish.


2. Is it good or bad if you have a well-planned algorithm?
3. Can an algorithm be used for any programming language, or is
it specific to only one programming language?
4. How important is it to follow instructions precisely, just as
how algorithms are important in programming?
Challenges:

1. Plan an algorithm to tell a robot to wash a dish.


2. Is it good or bad if you have a well-planned algorithm?
3. Can an algorithm be used for any programming language, or is
it specific to only one programming language?
4. How important is it to follow instructions precisely, just as
how algorithms are important in programming?
Warm up!
1. Think about everyday tasks, like getting dressed or frying an
egg.

2. Why is it important to follow a specific order of steps in these


tasks?
Robots and Sequences
• A sequence is a list of steps or instructions that are carried out
one after the other, in the order they are written.

• Each step is performed sequentially to achieve a particular task


or solve a problem.
Importance of Sequence
• A robot or computer relies on clear, step-by-step instructions
with correct sequences because they lack the ability to think or
make decisions by themselves.

• If the sequence is incorrect, robots do not recognize the


mistakes and this will lead to unwanted outputs.
Sequence helps you avoid mistakes and do things in the right
order.
Challenges:
1. Provide an example of real-life algorithm, similar to the shoe
wearing example, and explain the importance of following a
specific sequence in that task.

2. Have you ever played a game where you have to follow certain
steps? Why was it important to follow the rules?

3. Why do you think robots need people to tell them what to do,
while people can figure things out on their own?
• Bug- Error or mistakes

31
Debugging – finding and removing errors.

32
How to create a program?
• Start simple

• Plan the variables

• Create an algorithm

• Create a program
PictoBlox
• It is a graphical and Python programming software.

• It's user-friendly interface and drag-and-drop functionality


eliminate the need to memorize syntax.
Reference: https://ai.thestempedia.com/docs/pictoblox/pictoblox-tutorials/getting-started-
with-pictoblox/
Key terms
• Sprite - an object, or a character, which performs different
actions.

• Stage - the area where the sprite performs actions according to


your program.

• Script - a program or a code in PictoBlox. It is a set of ‘blocks’


that are arranged below one another in a specific order to
perform a task or a series of tasks.
PictoBlox has two modes:
• Stage Mode: In this mode, you can write scripts for the sprite
and boards to interact with sprites in real-time. If you
disconnect the board with Pictoblox, you cannot interact
anymore.

• Upload Mode: This mode allows you to write scripts and


upload it to the board so that you can use even when it is not
connected to your computer, for example, you need to upload a
script for making moving robots.
• To start the script, click green flag.

• To stop the script, click on the red octagon on the right of the
green flag.
Do you think a robot can make a decision itself?

6
4
1. Think about decisions you make in your daily life,
like choosing what to wear based on the weather.
2. How do you decide?
Conditional Statements
• A conditional statement in coding helps the robot or computer
to make a decision.
• It allows them to do different things based on whether a
certain condition is true or false.
➔ If the logical test is true, the computer does one thing.
➔ If the logical test is false, the computer does nothing or
another thing.
Conditional in a Flowchart

Conditional Statement Example


Real life examples
• If I’m hungry then I’ll eat cookies.
• If it rains then stay home.
• If you feel sleepy then sleep.
• If I have 500$ then I’ll buy snacks.
• If you have homework then do it.

• If I’m hungry, then I’ll eat cookies, else I’ll drink water.
• If it rains, then stay home, else go outside.
• If you feel sleepy, then sleep, else read books.
• If I have 500$, then I’ll buy clothes, else I’ll buy snacks.
• If you have homework, then do it, else watch movie.
Examples
Logical test : 5 > 3? 5 is greater than 3 ?
Answer: True
Logical test: 100 < 35 ? 100 is less than 35?
Answer: False
Challenges:
1. Imagine your robot has to decide whether it is daytime or
nighttime. What should it do for each case?
2. If your robot has a temperature sensor, could you use a
conditional statement to make it display a “too hot” or “too cold”
message depending on the temperature it senses?
• Conditional statement (If-then) and (if-else) is used to make
decisions in a computer program.
• (If-then) :If a condition is true, then an action is performed.
• (If-else) :If a condition is true, then an action is performed, else
another action is performed.

7
5
Repetition or Iteration
• Repetition in coding gives the computer the command to
repeat a specific task or set of instructions a certain number of
times or until a particular condition is met.

• It's also known as a loop.

• This is a way to tell a computer to repeat an action without


writing the same code several times.
Counter loop Conditional loop

Forever loop
Challenges:
1. Think of a task you do every day, like brushing your teeth.
How could you use a loop to explain the repetitive steps involved
in brushing your teeth?
Variables
• In coding, variables are considered as a placeholder for a value
that can be manipulated.

• Programmers create the variables to hold the value that will


change during the running of a program.

• For example, when you play a game, your score at the


beginning of the game is 0.

• The score changes as you play the game.


Fig- A variable named ‘age’ has a value of 10.
Ready-made variable in Scratch
Variable is a place to store value.
Challenges:
1. For a robot chef, what kind of variable will you use to store
the temperature of an oven?
2. In a game, why might you use a variable to keep track of the
player's score?

You might also like