0% found this document useful (0 votes)
28 views23 pages

MRSM SCRATCH-Ing Drone2022 Workshop - Scratch Programming

1. This document provides an introduction to programming with Scratch and discusses key Scratch concepts like statements, operators, expressions, conditions, loops, variables, threads, and events. 2. It outlines an exercise to make a sprite move in a square shape 20 times when the green flag is clicked using motion blocks and pen down, with wait statements to slow the movement. 3. Another exercise tasks the reader with making a sprite move according to arrow key presses, with different keys controlling up, down, left, and right movement.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views23 pages

MRSM SCRATCH-Ing Drone2022 Workshop - Scratch Programming

1. This document provides an introduction to programming with Scratch and discusses key Scratch concepts like statements, operators, expressions, conditions, loops, variables, threads, and events. 2. It outlines an exercise to make a sprite move in a square shape 20 times when the green flag is clicked using motion blocks and pen down, with wait statements to slow the movement. 3. Another exercise tasks the reader with making a sprite move according to arrow key presses, with different keys controlling up, down, left, and right movement.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

MRSM

SCRATCH-
ing
Drone2022
Workshop
MRSM Kuantan
5 – 7 August 2022

Instructor:
Assoc Prof Ts. Dr. Yasir Mohd Mustafah
Introduction to Programming
What is Computer Programming?
• What is programming?
• The process of writing, testing, and maintaining the code of computer
programs.
• “Telling the computer what to do”.
• Why learn to program?
• Develops logic and problem-solving skills.
• Improves attention to detail.
• It’s fun!
Computer Language
• Until recently, programming required knowledge of computer
language syntax
Programming Language
Anyone Can Program!
• New tools, like Scratch, allow ANYONE to create computer programs
without learning complicated syntax.
History of Scratch
• Scratch has become the world’s largest coding community for kids. In the past
year alone, more than 200 million children interacted with Scratch.
• Scratch launched in May of 2007 as a downloadable desktop application.
• The release of Scratch 2.0 brought Scratch to the web in 2013, resulting in
exponential growth in the Scratch community.
• The Scratch Foundation was established in 2013 as an independent nonprofit
organization.
• Mitchel Resnick, Professor of Learning Research at the MIT Media Lab, and
David Siegel, Co-Founder and Co-Chairman of the investment management firm
Two Sigma, are the original founders.
Scratch Programming
Statements
• In programming, a statement is simply a directive that tells the
computer to do something. Think of it as a command or an instruction.
• In Scratch, any block whose label reads like a command is a statement.
Operators
• An operator in a programming is a symbol that tells the
computer to perform specific operation and produce
result.
• The Operators blocks are used to compare variables and
values, do calculations with numbers, and work with text
(or String).
• There are maths operators, comparison operators, logic
operators and text / strings operators.
Expressions
• Sometimes, you only want a statement to be executed
under certain conditions. Such conditions are defined in
terms of Boolean expressions.
• In programming, a Boolean expression is an
expression that is either true or false.
• In Scratch, any block shaped like an diamond is a
Boolean expression.
Conditions
• In programming, a condition is something that must be
true in order for something to happen.
• A condition is thus said to "evaluate to true" or
"evaluate to false."
• In Scratch, any block whose label says "if," "when," or
"until" is a sort of conditional construct.
IF Statements
• If: Do something only if the expression is true

• If-Else: Do action 1 or action 2, depending on whether expression is


true of false
Until Statements
• Until: Do something until a condition is true.
When Statements
• When: Do something when an event occurs.
Loops
• In programming, a loop can create multiple executions of statements.
• In Scratch, any block whose label begins with "forever" or "repeat" is
a looping construct.
Variables
• In programming, a variable is a placeholder for some value, much
like x and y are popular variables in algebra.
• In Scratch, variables are represented with blocks shaped like
elongated circles, uniquely labeled by you.
• Variables can be manipulated using various blocks in Scratch.
Threads
• In programming, a thread is like a mini-program within a program
that can execute at the same time as other threads.
• In Scratch, any block whose label begins with "when" essentially
demarks the start of a thread.
Events
• An event is a signal from one thread to another.
• Blocks whose labels begin with "broadcast" signal events whereas
blocks whose labels begin with "when" handle events.
Scratch Exercise
Moving the Sprite
• Create a new sprite in Scratch, or just use the default cat sprite.

• Move the sprite using the motion blocks


(this motion blocks will not move the real world Tello Drone)

• Exercise: Make the sprite to move in square shape track 20 times when
the Green Flag is clicked. Use “pen down” instruction to trace the motion
of the sprite. Use “wait” statement to slowdown the movement of sprite if
it is too fast.
Controlling the Sprite
• Create a new sprite in Scratch, or just use the default cat sprite.

• Use the IF statement to detect key press, and depending on that key
press, move the Sprite.

• Exercise: Make the sprite to move according to the arrow key presses.
Arrow Up to move up, Arrow Down to move down, Arrow Left to
move left, and Arrow Right to move right.

You might also like