0% found this document useful (0 votes)
78 views67 pages

1 Scratch

Uploaded by

lmh10087215
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views67 pages

1 Scratch

Uploaded by

lmh10087215
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

Programming in Scratch

Part 1

충남대학교 | 박판근
Purpose 3

§ Programming is an important tool that computer scientists use in their work


ØComputer science and programming are NOT the same thing
ØComputer science is the study of how computers work and what we can do with th
em, while programming is simply one way to write out those solutions

§ Focus on
Øhow to use Scratch
Øbut also how to solve interesting problems and make cool things with the help of a
computer and Arduino
What is Scratch 4

§ Scratch: MIT's block-based programming language.


ØScratch is a programming language and online community
ØLifelong Kindergarten group at MIT Media Lab.

§ What can I do with it?


ØYou can create your own interactive stories, games, and animations
ØAnd share your creations with others around the world.
ØYoung people learn to think creatively, reason systematically, and work collaborative
ly
Strategies 5

§ Keep Scratch open.


ØPractice when you learn today!!
§ Think before you code.
ØIt's best to come up with a plan for your program before starting to put the blocks t
ogether.
§ Challenge yourself.
ØThe more time you spend using Scratch to create interesting programs, the better y
ou'll get. Learning to program is a lot like learning a foreign language
§ Review problems you answered wrong or didn't understand.
ØYou can learn a lot from your mistakes. If you get a problem wrong, or get the right
answer but aren't quite sure why it was right, take a look at the solution to the pro
blem.
(htt
Scratch Version 6
scr

Scratch 1.4 Sc
Installed onto a PC (or New
brow
Mac). Free to download.
onlin
requ
(http://scratch.mit.edu/
scratch_1.4/) (http

§ Scratch 1.4 (with Arduino) Scratch 2.0


§ Scratch 2.0
• Installed onto a PC (or Mac). Free to do • New version. Runs online in a brow
wnload. ser. Requires
New version. a login
Runs online in ato save online,
• (http://scratch.mit.edu/ scratch_1.4/) browser.but free toause.
Requires loginNo
toinstall
save required.
online,• but free to use. No install
• 그룹 프로젝트 필수 Arduino (http://scratch.mit.edu)
required.
§ ScratchX for Arduino
(http://scratch.mit.edu)
• https://scratchx.org/
Scratch Online 7

§ Scratch: MIT's block-based programming language.


§ Scratch will run in the following browsers
ØChrome 35 or later
ØFirefox 31 or later
ØInternet Explorer 8 or later
§ Visit http://scratch.mit.edu
Scratch Online 8

§ Creating a Scratch Account and Signing In

§ Once you've logged in, click on the "Create" button at the top left corner of th
e webpage.
Scratch Online 9

§ LOGGING OFF
Scratch Online 10

§ Saving Your Work

§ Naming Your Project


ØYou can change the name of your project by filling in the box at the top of the stage
, in the upper left portion of the screen.
Scratch Online 11

§ Changing the Language


ØThe Scratch website detects language from the browser settings.
Scratch Online 12

§ Posting Your Scratch Projects


ØBefore you post a link to your project, you need to share the project. Do this by pre
ssing the gray Share button in the upper right corner of the Scratch editor, under yo
ur Scratch username.

ØAfter you've shared your project, you will see the word "shared" in parentheses un
der the name of your project,
Scratch Online 13

§ The URL for your Scratch project should be at the top of the browser page.
Brief Outline 14

§ Unit 1: Moving blocks, creating scripts, and repeating blocks


§ Unit 2: Drawing with a computer
§ Unit 3: Tempo, variables, and the hat block
§ Unit 4: Coordinates and conditionals
§ Unit 5: Drawing with iteration
§ Unit 6: Broadcast and random numbers
§ Unit 7: Ask and join blocks, Scratch tools
§ Unit 8: Building your own blocks
15

Blocks area
Stage

Scripts area

Scratch editor

Sprites area
Scratch Lingo 16

§ Define new vocabulary words in our “Lingo List”


§ Tabs (for each Sprite):
Ø"Scripts", "Costumes", and "Sounds”

§ Sprite:
ØA sprite is a Scratch character.
ØEach sprite has its own scripts, costumes, and sounds.
Scratch Lingo 17

§ Tabs (for blocks):


Ølist of colored rectangles and types of blocks

§ Blocks:
ØDifferent colored blocks are used to do different things.

§ Script:
ØA script is a group of connected blocks that does something when you double click
on it.
Scratch Lingo 18

§ Costume:
ØThe appearance of the sprite on the stage. Each sprite can have multiple costumes.
Scratch Lingo 19

§ Stage:
ØThis is where you can see what happens when you run your scripts.
Moving Pieces 20

§ Creating Scripts
Ødrag some blocks onto the "Scripts" area.
Moving Pieces 21

§ Now try to connect the blocks to create this script below!

§ If you click on a block with the right button on the mouse ("right-click"), you sh
ould see "duplicate", "delete" and "add comment" options.
ØSelect "duplicate" to make a copy of the block you clicked on and all blocks below t
hat block.

§ Running Scripts
ØRun the script you made by double clicking on it (there should be a yellow glow aro
und it).
Repeat 22

§ When we want to do something over and over again, it took a lot of work and
a lot of blocks.

§ To make our work easier, we can use repeat blocks! Click on the "Control" tab.
ØA repeat block can do a snippet of code over and over again. The number next to th
e word repeat tells us how many times we want to do the things inside of the repe
at block.
Repeat (Quiz) 23

ØHow many times does the note 52 play when you double click the script below?

ØHow many times does the note 62 play when you double click the script below?
Repeat (Quiz) 24

ØHow many times does the note 52 play when you double click the script below? (0)

ØHow many times does the note 62 play when you double click the script below? (1)
Nested Repeats (Quiz) 25

§ We can put one repeat inside of another repeat!

ØHow many times will the note 62 play when you double click on this script?
Nested Repeats (Quiz) 26

§ We can put one repeat inside of another repeat!

ØHow many times will the note 62 play when you double click on this script? (6)
Complex Nested Repeats (Quiz) 27

§ How to keep track of complicated repeats.


ØHow many times does the note 55 play when you double click the script?

ØHow many times does the note 60 play when you double click this script?
Complex Nested Repeats (Quiz) 28

§ How to keep track of complicated repeats.


ØHow many times does the note 55 play when you double click the script? (4)

ØHow many times does the note 60 play when you double click this script? (2)
Exercise : Make a Song 29

§ Start by making a new project in Scratch. Click on "File" in the gray bar at the t
op of the screen and you'll see a menu pop up. Click on "Go to My Stuff".

§ Now click on the button that says "+ New Project".


Exercise : Make a Song 30

§ To make your song, you can try using any of the blocks in the Sound tab.
Exercise : Make a Song 31

§ You can make more than one script with a "green flag" block on top. That way,
when you click the green flag, more than one script will play! This is called par
allel execution.

§ Push your thinking, make the coolest song imaginable! Try to use multiple instr
uments - we recommend at least three.
How to Post Your Project 32

§ "This is my song project. I tried to make two different sets of notes play at the
same time!
https://scratch.mit.edu/projects/46115042/#editor"
Computer Science Lingo 33

§ Keep thinking of more computer science lingo as our class continues!


Brief Outline 34

§ Unit 1: Moving blocks, creating scripts, and repeating blocks


§ Unit 2: Drawing with a computer
§ Unit 3: Tempo, variables, and the hat block
§ Unit 4: Coordinates and conditionals
§ Unit 5: Drawing with iteration
§ Unit 6: Broadcast and random numbers
§ Unit 7: Ask and join blocks, Scratch tools
§ Unit 8: Building your own blocks
Intro to Drawing 35

1 px = 0.026458 cm
Intro to Drawing 36
Drawing in Scratch 37
Reset Script (Tips) 38

§ When we're drawing in Scratch, it's helpful to be able to reset the stage. Reset
ting the stage moves the character to the center of the screen and removes ol
der drawings from the stage.
Drawing a Square 39

§ Hints : The blocks below will probably be helpful too!

§ Any better way?


Saving Time and Avoiding Errors with Repeat 40
Drawing a House (Quiz) 41

§ We want to draw a picture of house with a square on the bottom and a triangl
e on top. We wrote the script below to do this.
Drawing a House (Quiz) 42

§ We want to draw a picture of house with a square on the bottom and a triangl
e on top. We wrote the script below to do this.

§ The script above draws the image below.


Think : Drawing a House 43

§ Having multiple solutions to the same problem is common in computer scienc


e! We came up with two different ways to solve this problem.
Exercise : Drawing a Triangle 44

§ We can use a REPEAT to make drawing shapes a lot easier! Here is a script to d
raw a square.

§ Using a REPEAT try to draw the following shape, an equilateral triangle:


Exercise : Drawing a Circles with different radius 45

§ Hint
Exercise : Draw a Pentagon 46

§ Use Guess and Check to have the sprite draw a pentagon in Scratch.
Exercise : Draw a staircase 47

§ Draw a staircase across the Scratch stage using repeat.


Exercise : Dotted Line 48

§ Draw a dotted line that goes across your Scratch screen. Hint: You should use r
epeat.
Exercise 49

§ Which picture does this next script draw?

§ Fill in the blanks to draw a 9-sided shape. You might have to do some math to
figure out how many degrees to turn!
Brief Outline 50

§ Unit 1: Moving blocks, creating scripts, and repeating blocks


§ Unit 2: Drawing with a computer
§ Unit 3: Tempo, variables, and the hat block
§ Unit 4: Coordinates and conditionals
§ Unit 5: Drawing with iteration
§ Unit 6: Broadcast and random numbers
§ Unit 7: Ask and join blocks, Scratch tools
§ Unit 8: Building your own blocks
Sound Block 51
Sound Block 52
Tracking Tempo with Set and Change (Quiz) 53

§ What is the value of tempo after we run this script?

§ What is the value of tempo after we run this script?


Tracking Tempo with Set and Change (Quiz) 54

§ What is the value of tempo after we run this script? (90)

§ What is the value of tempo after we run this script? (60)


Changing the Tempo in a Repeat (Quiz) 55

§ What will be the value of tempo be after the following script is run?
Changing the Tempo in a Repeat (Quiz) 56

§ What will be the value of tempo be after the following script is run? (110)
Why and How to Use Variables to Play Scales 57
Playing a Sequence of Notes 58
Variable Tutorial 59

§ We're going to make a script that plays a scale, and we'll create a new variable
for it!
ØYou've already used some of the pre-made variables in Scratch, like tempo.
§ Click on the "Data" tab and click "Make a variable.”

§ In the box that pops up type the name of our new variable, "my note".
Variable Tutorial 60

§ Now you'll have blocks to use for your variable.

§ Make the script on the right using your


variable "my note."
Why Order Matters in the Iteration Pattern 61
Updating Variables in a Repeats (Quiz) 62

§ Write out the numbers of the notes that will be played when this script is run.
Updating Variables in a Repeats (Quiz) 63

§ Write out the numbers of the notes that will be played when this script is run.

§ (15, 20, 25, 30, 35)


Exercise: countdown 64

§ Write a script that makes the sprite count down from 10 to 1. Use a variable n
amed . Use the same methods you used for changing the tempo.
Exercise: countdown 65

§ Hints
ØYou need to use the repeat block.
ØYou need to use this piece , which you will find in the "Looks" tab.

ØReplace "Hello!" with your variable


ØThere are 3 different ways you can get the to decrease by 1:
Exercise : Tracing Nested Repeats 66

§ Write out the numbers of the notes that will be played when this script is run.
Electric Keyboard 67

§ In Scratch you can tell when a key is pressed, and do something!


ØLook at the Events tab and you'll find a piece near the top that says "when _______
key pressed."

ØHere we picked key "a". Then when that key is pressed, Scratch will play note 60.

You might also like