Saturday

Introduction to Scratch Programming for ICSE Class 5

ICSE Class 5 Computer Studies

This lesson will give students a brief introduction to Scratch programming. I am using Scratch3 Desktop software on Windows computer. The lesson is created according to ICSE syllabus for Class 5th.

Introduction to Scratch Software

Scratch is a block based visual programming language. Blocks are the puzzle piece shapes that are used to code in Scratch. The current version of this software is Scratch 3. Scratch has an online editor on their website, which can be run directly in the browser or you can download and install the editor on your computer and run it from there.

Open the Scratch

If you have installed Scratch on your computer, you will see an icon of Scratch on the Desktop. Double click on it to start the Scratch Editor.





As you can see in the above image. The Scratch Screen is divided into several sections. The leftmost area is called “Block Palette”. It contains color-coded block categories. When you click on one of these colored dots, the blocks in that category appear in the right column.
The middle portion is where all your code will reside. This is the area for creating scripts for you.
The upper-right area is called the stage area. It will house all the sprites in your project, And this is where all the action of your project can be previewed. Below the stage there is sprite-info pane. You will see smaller images of the sprites that you add in the stage area.

Components of the Scratch 3 Editor

Stage and Sprite


The rectangular area at the right side of the Scratch Editor is called the Stage. This is where all your sprites ( cartoon images) appear. There is always a cat present when you open your Scratch. The cat is a sprite. And it will appear in the area that is called the Stage.


Sprite info pane

This is the area below the stage. This is where you will find smaller images of the sprites you have added in the stage area.

Blocks

Blocks are the puzzle piece shapes that are used to create code in Scratch. The blocks connect to each other vertically like a Jigsaw puzzle.
There are different shapes of these blocks. They are called Hat blocks, stack blocks, reporter blocks, Cap blocks etc

The blocks are arranged in color-coded categories that appear at the left most column in form of colored dots. When you click on one of these categories, the block in that category are displayed in the next column. We will learn some of the categories like Motion, Looks, Control and Sound in this lesson.










The Green Flag and the Stop signs

Above the stage area there are two distinct symbols. One is a Green Flag and other is a Red colored stop sign. The Green flag is used to start your Scratch script, and preview it in the stage area. And the Red stop sign is used to stop the script. You will need to use these two buttons often to run and to stop your scratch code.



The Script Area


The middle portion of the Scratch 3 editor is used as the script area. You can drag the code from the “Code palette” into this area and create scripts. You can also drag a code block from this area to the left pane so that you can remove or delete that code block.






Adding a sprite


You can add new (images) sprites in your project. When you take the mouse pointer on the cat-head icon in the sprite-info pane, you will see a menu pop up. If you click on the magnifying glass icon, it will open a new page in the Scratch library of images, where you will be able to choose any image you like.



The brush icon called paint open an image editor, where you can draw an image to add it in your project.

The topmost icon is for uploading any image that is available on your computer. You can use any image from your computer to be used as a sprite in your project.













Changing a backdrop


In the right of sprite info pane, there is a stage-pane. You will see an image icon there. If you take the mouse pointer on it, a menu pops up with a message “Choose a backdrop”. If you click on the magnifying glass icon, it opens the backdrop library. You can choose any background image here for your project.










Add Extension


If you click on the icon in the bottom-left corner of the Scratch Editor, (It is called Add-extension) It will open a new page that shows several extensions like Music, Pen, Text-to-speech etc. If you choose any of them, it will create a new Category in the blocks-palette. And you will see many new blocks in that category. We will study the music extension and the pen extension in this lesson.

Saving a project


When you have done some work in your new scratch project, you can save it.
To do that Click on File menu in the Toolbar and choose “Save to your computer”
It will show the folder on your computer. You need to select here the right folder where you want to save your scratch project. You should remember the folder name, otherwise you will find it difficult to find your scratch project on your computer. You need to give a name to your project. Once it is saved, it will have an extension .sb3 , That is the file extension of the Scratch 3 editor. If you need to save your file again after some time you can select the previous file name again and overwrite it, or you can give a new name such as myproject-v1, myproject-v2 etc. Scratch offline editor does not save your file automatically. You need to save it yourself each time.
Opening an existing project

If you want to open your project at some other time, you need to click on File – Load from your computer, and then open the folder where your scratch projects are saved, and then select the sb3 file, that will open the scratch project in the scratch editor.

Closing a project

You can close the editor by clicking on the x sign at the top right corner of the editor. That will show you this dialog box. If you have not saved your project then you can
select to Stay, then save the project. If you have already saved your project then select to Leave. That will close the Scratch Editor.



Block Categories in Scratch

Motion Blocks


Motion blocks is one of the categories of blocks in Scratch. They are color coded medium blue and are used to control sprite movement.

The blocks that can be arranged one below the other are known as Stack blocks. There are 15 such blocks in the Motion category.


The blocks that give certain information into the script are called “Reporter blocks”. There are 3 reporter blocks in the Motion category.



Looks Blocks



The Looks category blocks are color-coded Purple. These blocks are used to control a sprite’s appearance.

There are 17 Stack blocks and three Reporter blocks in this category.















Sound Blocks


Sound bocks are color-coded Pink/Magenta. These blocks are used to control/add sound and MIDI functions.



























Music Blocks

 
These blocks are added as an extension. They are color-coded Green. They can be used to generate musical notes of different instruments in your Scratch project. It is a music making tool. You need to have a teacher who understands musical composition to make god use of this extension. You will have fun in using this extension which can create music through programming.
If you click on the instrument name, you will see a list of dozens of musical instruments to choose from, and you can select the node and beat value for that instrument to play.














Control Blocks

Control blocks are color-coded in Golden color. These are used to control the script.




There are 1 Hat block, 5 C type blocks, 3 Stack blocks and 2 Cap blocks. Cap blocks are the ones that are at the bottom of the script. C type blocks are those, which can include other blocks inside them. They are also called Loops. Hat block is the one that is at the top of a script.







Commonly used blocks in Scratch


Move, Turn, Say, Think, Change-color effect, Play-sound, Play-drum, Wait, Forever.



Move block – This block is found in the Motion category. It will move the sprite a number of steps in the current direction. The value is 10 when you add this block. You can type in any number in the box. You can make the sprite move in the opposite direction if you type a negative number.

Turn – This block is found in the Motion category. There are two types of turn blocks, Clockwise and Anti-clockwise. When you add these blocks, there is 15 written in it. It will turn the sprite 15 degrees. You can type any number in it (0 to 360).

Say – This block This block is found in the Looks category. It will add text in a speech bubble. When you add this block, there is “Hello” written in there. You can type anything you like in the box.

Think – This block This block is also found in the Looks category. It is similar to the Say block, except, it is not addressed to anyone. You can use this block, if you want to show that your sprite character is thinking something. It is useful if you are creating a story using scratch.

Change Effect by - 

This block This block is also found in the Looks category.
You will find a list of 7 different effect to choose from. The already written value ids 25.
You can type a different number ( from 0 to 100 or -100)
You can change the color, brightness and visibility of the sprite. You can also make some visual effects such as fisheye, whirl, pixelate and mosaic.














Play sound - 



This block is found in the Sound category. When you add any sprite, and then add this block, you will see one or two sounds that are suitable for the sprite. You can additionally add more sounds if you want by clicking on the Sounds tab at the top left corner of the screen. Or you can even record your own voice if you want.

Play Drum -






You will find this block in the newly created Music category if you have added the music extension in your Scratch Editor.
The play drum block has a list of 18 different instruments to choose from. And you can specify the beats.











Wait - This is a golden colored Control block. You can use this block to make things wait for as long as you want. There is 1 seconds written when you add this block. You can add a bigger number to make it wait longer. This is a Stack type block. Yo u can add other blocks above and below this one.



Forever - This is also a control block. It is called a C type block because it looks like a C. It is also called a Loop. We can add other blocks above, and below this block, but also we can add other blocks inside this block. Whatever we add inside this block, will run on and on till we do not stop it with Stop block , or by pressing the Red stop button.


Let us see some action in the video tutorials below. 

Tutorial 1


Tutorial 2


Tutorial 3


Featured Post

Creating Games in Scratch for ICSE Class 6

An Introduction to Creating Games in Scratch  for ICSE Class 6 Hello friends, I hope you have already read the previous post on An Int...