P5_3_robotics,_algorithm,_program_and_sequence,_conditional,_loop
P5_3_robotics,_algorithm,_program_and_sequence,_conditional,_loop
P5
Challenges:
1. How do you understand a robot?
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.
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.
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.
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.
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
• Create an algorithm
• Create a program
PictoBlox
• It is a graphical and Python programming software.
• 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
• 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.
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.