ALGORITHMS AND PROGRAMMING - Scratch

     SCRATCH is a free, block-based, visual programming language.  It can be run online or downloaded and run offline.  It works on Macs, PC's, and Chromebooks.  There are numerous resources for learning, and teaching, SCRATCH, including tutorials, sample programs, how-to guides/videos, books, and websites.  While it is often considered a language for young children, it is quite sophisticated and can be used to create interactive, multimedia animations and games, interfaced with data collection devices such as the Vernier Force sensor, and used to control a number of devices such as robots and drones.  It also provides a number of opportunities for integration programming across the curriculum, and I'll be discussing Google's CS First project in some detail.
     SCRATCH is also the model for a number of other programming languages.  Learning SCRATCH will make it much easier to code in SNAP or ArduBlock or to program the Microbit or the Makeblock robots.  It is also great preparation for participating in Hour of Code activities.  SCRATCH Jr provides a great introduction to coding (and SCRATCH) and is available as a free app for IPads and Android tablets.

     To get started, go to the SCRATCH website, www.scratch.mit.edu, and click on the Join SCRATCH option in the upper right hand corner.  This will give you an account with SCRATCH which will be helpful if you wish to save and share the programs you create.  You can also take a quick look at some of the sample programs listed on the site.  During training sessions, I usually ask people to take a look at the Dancing Crab program: https://scratch.mit.edu/projects/11483977/
     This is the screen you'll see.  A couple of things to note - clicking on the green flag starts the program, clicking on the red stop sign stops the program.


     And clicking on the See Inside option let's you see how the program works:


     It might a bit confusing at first, but it's actually pretty straightforward.  The general idea is that you choose a background, choose a character (called a sprite), and then program the sprite to do something.  There are many pre-loaded sprites and backgrounds, or you can design your own or upload as an image.  You can have backgrounds change and you can have lots of sprites - each with it's own program.  We'll take a close look at the Dancing Crab program, and as we do that, I'll be highlighting certain terms in bold red.  These will be key terms from the CS standards.
     We'll start with the first column on the left, the colored circles.  Each circle is a kind of programming command.  When you click on a particular circle, the various commands for that category appear.  In the image above, the Blue circle (Motions) is clicked and you can see several of the motion commands in the second column.  There are commands like Move, Turn, Go To, Slide.  As you click on each color circle, the commands for that category will appear.  Clicking on the light orange Events circle will bring all the events commands into view.
     The third column is where you build your program by dragging commands from the second column.  When you start a program, this space will be empty.  In the example above you'll see the Dancing Crab program in that space.
     The fourth column is kind of like a stage where the program plays out.  It's also the location for the New Sprite and New Background buttons.  And at the top of this column you'll see the green flag for starting your program and the red stop sign for stopping it.

     Let's talk about how this program works.  When you start a new program (choosing the Create button on the opening screen) the third column will be blank, and in the fourth column you'll see a white background with the Scratch cat on the screen.  The programmer clicked the Choose a Backdrop button in the lower right hand corner.  Then the Paint icon, chose the color blue, then used the fill command to create an all blue background.  Take a look at the magnifying glass icon choice to see some of the pre-loaded backgrounds that can be used.  Next, the Choose a Sprite button (next to the Backdrop button.)  Click on the magnifying glass option and you'll see lots of choices - from the animal section, choose the crab.   Now, you'd have two sprites - the cat and the crab.  You only need the crab for this program so click on the cat icon that's in the small window with the Choose a Sprite button.  You should see a small trashcan icon in the upper right hand corner.  Click the X and the Cat sprite disappears.
     Now you have a single crab sprite on a blue background.  To program the crab, you're going to be selecting various commands and dragging them into the empty third column.  You need to start the program, so click on the Events circle.  You want this program to start when the green flag is clicked, so drag that command into the space.  That's an Event - something will happen when the Event takes place (in this case, clicking the green flag is the Event.)  Notice - there are three things that are going to start, each with it's own green flag Event to get it started.  All three things will start at the same time - you don't need to click the flag three times.  The first action is Motion - Blue blocks.  In this case, a block for sending the crab to a specific location (middle of the screen) and then setting rotation to Don't Rotate.  Then, some more blue motion blocks, but this time they are inside a dark orange Control block.  This tells the program to repeat the blue blocks inside forever (or until the program is stopped.)  This is an example of a Loop, a set of actions repeated until something happens to stop it.  Some Loops are forever and some can be set to a specific number of repetitions, or Iterations.
     There are two more parts of the program, both started with the click of the green flag.  One controls the appearance of the crab, the other controls the sound being played.  Notice that both use an Event (clicking the flag) and a Loop

     So, in a very simple program, you've used some of the key concepts from the Virginia CS Standards: Events, Loops, and Iterations.

     This has been a very simple introduction to how Scratch works.  There are many, many resources available for learning more about the language.  I've listed some in the Resources section.  A good way to start is to look Inside some example programs and see how folks have made different things happen in their program.  Also take a look at the page Scratch has developed for educators: For Educators: https://scratch.mit.edu/educators/




Comments

Popular posts from this blog

COMPUTATIONAL THINKING FICTION BOOKS

UPDATES

DATA COLLECTION AND ONLINE LEARNING WITH THE MICROBIT