Print bookPrint book

Scratch Coding + Scratch-Link WiInterface Game Controller

Site: StemAcademy: Projects & Resources - Maker Space - Coding & Robotics
Course: StemAcademy: Projects & Resources - Maker Space - Coding & Robotics
Book: Scratch Coding + Scratch-Link WiInterface Game Controller
Printed by:
Date: Monday, 20 May 2019, 12:50 AM

1. Introduction

This e-book is aimed at helping Teachers, Librarians, Parents and self-learners by providing learning and support resources for:

You will be able to:

  • Setup ScratchLink
  • Learn Scratch
  • Teach Scratch and utilise the many teacher resources either as class lessons or after school clubs or library engagement sessions
  • Utilise Units of work for Coding and Robotics based on Scratch and Scratch-LInk
  • Sequence, scaffold and differentiate your coding units with our resources rated for Beginner, Intermediate & Advanced with both Core and Extension level exemplars provided for every project

Do I need to buy Scratch-Link to get started?  No, the Scratch only units do not require any extra hardware.  Get started and move into physical computing and robotics with Scratch-Link etc later.

2. ScratchLink Setup

ScratchLink is a family of hardware that allows Scratch2 offline to directly interface with robotics and microcontrollers and various sensors and hardware i.e. Arduino and EV3 Lego etc.  ScratchLink currently only works with Windows OS but when Scratch3 rolls out in Aug 2018 it will be browser based and will work with all operating systems including IOS. ScratchLink will work with browser based Scratch3 so Ipads, Macs, Linux and Windows systems will all use the same browser plugins.  ScratchLink has an Arduino compatible microcontroller that connects to your computer with the USB cable and sometimes you may need to manually update the USB driver if Windows does not auto detect.  You also need to run the ScratchLink Helper App while interfacing between Scratch2 Offline and ScratchLink which also authenticates the ScratchLink as genuine.

ScratchLink USB Setup:

Check USB Port: When you plug in ScratchLink with the USB cable windows should auto detect the serial USB chip.  ScratchLink could have either the CH340 or Silicon Labs USB chip.  To check this in Windows goto your "Control Panel" then "Device Manager" the "Com Ports- You should see one of the COM ports showing either "USB-SERIAL CH340(COM#)"  or "Silicon Labs CP210x USB to UART Bridge(COM#).  If you see this then note the COM port number- if there are lots of COM ports showing and you don't know then watch the list and remove ScratchLink from the USB port and not the entry that disappears- this is ScratchLink.


Install USB driver if needed:  If you got "Serial Device?" or similar in the first step then Windows does not have the USB driver.  So we need to "update" the driver.  Download and unzip the CH340 USB Driver then "right mouse click" the entry in COM ports (Device Manager) with the "Serial?" or "Unknown Serial Device" - upon "right click mouse" select "update driver" then navigate the folder of the unzipped CH340 USB Driver.  ScratchLink should now appear as "USB-Serial CH340(COM#), if not then it could need the Silicon labs driver, in which case download and unzip the Silicon Labs USB Driver and run the executable install file for either 32 or 64 bit machine.

Start ScratchLink Helper App:  Download, unzip and copy the ScratchLink Helper App to your prefered folder and make a shortcut to the desktop if desired.  Start ScratchLink Helper App and "allow" it to get past the windows firewall if you get warnings.  Plugin ScratchLink hardware such as WiInterface and it should populate the COM port dialogue box at the top of helper app.  Press "connect hardware" and then "test LEDs" whereupon the LEDs on the WiInterface should do a quick multicoloured demonstration.  The "Hardware" box should show "USB connected" and be green.  If no COM port displays at the top then you need to install the USB driver as above or you didn't plug in the USB cable or maybe try another COM port or rebooting.  When you start Scratch2 Offline the "Scratch" dialogue will show green and "connected" in the helper app.  You must have the helper app going to use ScratchLink.

Install Scratch2 Offline:  Install Scratch 2 Offline Editor on local computers or use a network MSI for Scratch2.  You will need Adobe Air and make sure that your Adobe Flash is up to date before installing the latest Scratch2.

Import your ScratchLink blocks into Scratch2 Offline by holding down "Shift" then click "File" and "Import experimental HTTP extension" and navigate the ScratchLink Blocks that you which to import.  Note that imported blocks can't stay inside Scratch itself but if you simply save an empty project file after importing the blocks and start Scratch using this empty project then the imported blocks will be available.  This is because imported blocks are stored with the project itself i.e. "Scratch2 project file" not inside the Scratch2 program itself.  

Download and unzip desired blocks below.  The imported ScratchLink blocks will show under the "More Blocks" tab in Scratch2 and if you have a ScratchLink plugged in and the helper app going then the dot in "More Blocks" will be green not red, indicating a live serial connection from Scratch2 to ScratchLink.  You can can now start interfacing with ScratchLink directly from Scratch with Scratch coding.

WiInterface Scratch Blocks (Nunchuk)

WiInterface Scratch Blocks (Classic Controller)

WiInterface Scratch Blocks (Nunchuck & Classic Controller )

Lego EV3 Scratch Blocks for ScratchLink

Lego NXT Scratch Blocks for ScratchLink

Sphero Scratch Blocks for ScratchLink




3. Scratch2 (MIT) Coding

Scratch 2 is the current version of the highly acclaimed educational visual programming language (VPL) from Massachusetts Institute of Technology (MIT) Media Lab.  It is designed as an easy and fun introduction to programming for kids 6-16 years of age.  Watch the Sractch2 Overview video below.




3.1. Software- Scratch2 Offline

You can create scratch animations and programs using Scratch Online through your browser.


However it is usually best for educational purposes to install Scratch 2 Offline Editor on computers so that an internet connection is not required (Mac & PC).  There is also a network MSI for Scratch.

Scratch programs created in the offline editor are interchangeable with the online editor- so this is an excellent feature that allows students to work on their projects from home or their device that can access Scratch Online.  


3.2. Online Help Resources

You will need a Scratch Online account for some of the help resources but not all.

The Scratch Team have provided some printable pdf resources being the Getting Started Guide and a series of Scratch Cards, plus the following introduction to Scratch Video.


ScratchEd is an online community for Scratch Educators. Scratch Wiki contains a Scratch Reference Manual and other useful resources.  The main Scratch site also has a discussion forum.  However these are probably not necessary for educators to start delivering introductory Scratch Coding but are quite useful for complex or unusual projects.

It can be useful to get some ideas from other online Scratch users by exploring online projects or utilising Scratch Studio which s a collection of tutorials contributed by users.  Please take note that while other user's online user projects and tutorials can sometimes be useful they are sometimes of limited usefulness and quality for classroom use.

3.3. Online Starter Projects

The Scratch website has lots of Starter Projects (require Scratch Online account) covering:







3.4. Online Scratch2 Tutorials

The MIT Scratch Team have created a series of  useful Video Tutorials:


 



The Scratch Team have also produced a series of Video tutorials concerning creating backdrops and sprites using the Paint Editor

3.5. Scratch2 Offline Help

This section refers to using Scratch 2 offline i.e. Scratch 2 installed onto your computer that you run as a "program" not the Scratch website that runs through your browser over the internet to the MIT server.  Install Scratch 2 Offline Editor if you haven't already done so or get your IT admin to use the network MSI for Scratch 

Scratch2 Offline: Functional Overview and Help Menus

 

3.6. Class Tips for Scratch2

Classroom Tips for Scratch2 Offline 


3.7. Project Rating & Sequencing

Scratch2 and all the resources provided on StemAcademy are suitable for learners from early Primary through to Middle School.  At the present time many different year levels are starting coding for the first time and will need to start at roughly the same place.  However the speed and depth of learning will vary greatly depending on the learner.  Rather than thinking of coding as a narrow set of procedural skills or knowledge it is better to focus on the underlying complex reasoning, analytical and communication skills as with other branches of science and maths.

Scratch2 could just be a tool to create simple animations, however, it is also a powerful tool for Project Based Learning(PBL) as is its extension into physical computing with ScratchLinks and robotics.  Using Scratch2 and PBL can have great learning outcomes and engaged classrooms for mainstream classes with a broad spectrum of types of learners at various levels.  However, it's important to keep projects as concrete and cognitively simple as possible in the beginning and sequence coding concepts from beginner to advanced as in the tables below.  Differentiating for diverse levels and styles of learning is possible with appropriate scaffolding and exemplars.  PBL can be equally successful with concrete thinkers with low complex reasoning skills and abstract thinkers with high reasoning and communication skills.  The examples given below are to help educators plan learning experiences.  

All of the projects provided will utilise the learning and sequencing concepts listed below and rated from Beginner to Intermediate and then Advanced.  Furthermore, each Beginner, Intermediate or Advanced level project will also provide both Core Tasks and Extension Tasks.  Combined with our support resources and full exemplars this allows for appropriate scaffolding and differentiation to cater for a wide spectrum of learners in mainstream classes.  




4. Scratch Projects (Examples & Tutorials)

This chapter is an example of a Scratch Unit of work of about 10-25 hours depending on prior experience and skill level etc.  It includes two separate threads of Core and Extension level projects throughout for differentiation.  It could be done initially with just the Core level projects and then revisited with the Extension level projects or done all at once depending on your needs.

This chapter also serves as support material and exemplars for the Scratch Coding Challenges.

Please ensure that you have a rudimentary working knowledge of Scratch by reviewing Chapter 1 and if you are an educator then please review Class Tips for Scratch and the Project Rating and Sequencing used here.




4.1. Animation- Project Intro (Beginner)(Core & Extension)

Animation- Generic Project Intro

Level: Beginner (Core & Extension)

Task Sheet: Word or PDF

Robotics Hardware required: None

Prerequisite:  Learnt the basics of Scratch, considered Scratch Classroom Tips and Project Rating and Sequencing

Starter Code with Tasks (Core & Extension)

Core Tasks:  Create a Scratch Animation that will serve as an introduction for your future Scratch Projects and contains:

  1. Project overview
  2. Team introduction
  3. Explanation of how your introductory animation works with an algorithm and code comments

Extension Tasks: Utilise the following animation techniques:

    • Shrink/Grow
    • Change colour
    • segment transitions using backdrops, effects or sprite clicks etc
    • multiple costumes for the same sprite


Resources, Exemplars & Video Tutorials:

1. Scratch.mit.edu Online (MIT Server) Examplars: 



2. Scratch Offline Editor Exemplars: (i.e. run on your PC not via internet)

Core Exemplar: Animation- Project Introduction (Core Only).sb2

Extension Exemplar: Animation- Project Introduction (Core Only).sb2


3. Video Tutorials for this task:


4.2. Animation- Pong Algorithm (Beginner)(Extension Only)

Animation- Pong Game Algorithm

Level: Beginner (Extension Only)

Robotics Hardware required: None

Prerequisite:  Learnt the basics of Scratch, , considered Scratch Classroom Tips and Project Rating and Sequencing

Starter Code with Tasks (Extension only)

Extension Tasks: Utilise the following animation techniques:

    • Shrink/Grow
    • Change colour
    • segment transitions using backdrops, effects or sprite clicks etc
    • multiple costumes for the same sprite


Resources, Exemplars & Video Tutorials:

1. Scratch.mit.edu Online (MIT Server) Examplars: 

2. Scratch Offline Editor Examplars: (i.e. run on your PC not via internet)

Pong Algorithm Exemplar (Extension)

 

3. Video Tutorials for this task:

Please note that this task is Beginner Level but Extension only even though the video tutorial refers to it as Core- its was upgraded to Beginner (Extension) from Beginner (Core).

4.3. Pong Game (Beginner)(Core & Extension)

Animation Example & Tutorial  : Pong Game (Beginner)

Level: Beginner (Core & Extension)

Task Sheet: Word or PDF

Robotics Hardware required: None

Prerequisite:  Pong Starter Game tutorial by the Scratch Team which is in Scratch2 offline Editor/ Tips /Step-by-step/ Create a Pong Game

 Learnt the basics of Scratchconsidered Scratch Classroom Tips and Project Rating and Sequencing

Core Tasks: Starting with the Pong Starter Scratch Code (from Scratch Team) add the following features:

  1. Change the Ball Sprite Costume
  2. Change the Paddle Sprite
  3. Change the backdrop
  4. Control the paddle movement with the keyboard arrow keys
  5. Adjust the difficulty appropriately with the speed of the ball and responsiveness of the paddle
  6. Provide an algorithm of your code action and control logic either flow chart or english list
  7. Comment your code with brief explanations of the logic or actions of blocks but do not repeat the block words
  8. Test and evaluate your final code- state how well it meets the core task?  How would you improve it?
  9. Put all of the above in your scratch code or as directed by your teacher
  10. Save all your work with your name and task, i.e. "Johnny_B_Pong.sb2"

Extension Tasks:

  1. Apply appropriate duration sounds to sprite interaction- i.e. ball hitting paddle and ball getting out.
  2. Change sprite costume with sprite interactions
  3. Create multiple balls
  4. Create two paddles and control one with the mouse and one with the keyboard
  5. Update your algorithm, code and comments appropriately


Resources, Exemplars & Video Tutorials:

1. Scratch.mit.edu Online (MIT Server) Examplars: 


2. Scratch Offline Editor Examplars: (i.e. run on your PC not via internet)

3. Video Tutorials for this task:


4.4. Merge Scratch Projects

Complete Project by Merging Animations

Make a Plan

I would like to bring everything together into the one big animation project and I'd like to use the extended versions of my projects.  So my animation would have the following:

  • Project Introduction animation (extended)
  • Pong Algorithm animation
  • Pong game animation
  • Transitions between the animations requiring user keyboard input

The three animations are already done but I need a plan for:

  1. Merging all the code from the three separate animations: sprites and their code can be saved to a file and then imported into another animation so this will allow me to merge all the sprites and code into one animation.
  2. Triggering the transitions between animation segments:  I plan to change the backdrops of the beginning and ends of the 3 animations and use the Event "When backdrop changes to?" to start the next animation (group of sprites)


Merge all Sprites and Code

Merge the smaller programs (Scratch Animation) into the larger one.  So, I will merge the Pong Game Animation Sprites and Backdrop into the Project Introduction Animation as that has 5 Sprites while the Pong Game only has two, so this saves work.  Make separate folders and save all your Sprites and Backdrops from each animation.  The video below shows how.


Create Transitions and Create Single Merged Animation (core)

Video Tutorial:

In this example we are going to signal the Pong Game to start i.e. transition from one animation section to the next by signalling using the changing of Backdrops. This video explains how?


Exemplar (Example Finished Animation):

Combined Animation of Intro and Pong (offline)

Combined Animation of Intro and Pong (online)


Extended Merged Animation- Intro(Ext) + Algorithm + Pong Game (Ext)

If you have been doing the Extension projects then we can now merge all three i.e. extension introduction, pong algorithm and the extension pong game.  

This task requires good planning, custom naming/saving and ordering of files to avoid confusion.  Consider the following when planning this task:

  • Save all the sprites and backdrops from the Pong algorithm animation and the extension pong game with appropriate names and in folders so that you don't get mixed up
  • Start with the first animation segment i.e. open up the Extension Intro to Project Animation and then import the Pong Algorithm Sprites and Backdrop and then lastly, the Extension Pong Game Sprites and Backdrop- this will put all your Sprites in order of the Animation sequence i.e. Intro - Algorithm - Pong Game.
  • Use something to transition or signal between animation segments (backdrops used here)
  • Find the final thing to happen i.e. sprite to place the transition signal (change backdrops block)
  • Sprites from the first two animation segments will need to be hidden after they have finished otherwise they will continue to show in the next animation segment so use the hide block

Exemplar (Example Finished Animation):

Extension- Combined Intro+Algorithm+Pong Animation (offline)

Extension- Combined Intro+Algorithm+Pong Animation (online)


Video Tutorial:

5. Scratch-Link Projects

Scratch-Link Projects

5.1. NunChuk Buttons&LEDs+Pong Game

NunChuk Buttons+Pong Game (Beginner)

Level: Beginner (Core & Extension)

Hardware required: WiInterface, Funster or ScratchLink with NunChuk

Prerequisite:  Pong Starter Game tutorial by the Scratch Team which is in Scratch2 offline Editor/ Tips /Step-by-step/ Create a Pong Game

Core Tasks: Starting with the Pong Starter Scratch Code add the following interactivity with physical hardware:

  1. LEDs to illuminate appropriate colour and duration when ball is struck by paddle and when ball gets out and game is over (outputs)
  2. Control the paddle movement with the Nunchuk buttons (on/off or 0/1 i.e. digital inputs)
  3. Adjust the difficulty appropriately with the speed of the ball and responsiveness of the paddle via the Nunchuk
  4. Change the sprites and backdrop to something appropriate
  5. Provide an algorithm of your code action and control logic either flow chart or english list
  6. Comment your code with brief explanations of the logic or actions of blocks but do not repeat the block words
  7. Test and evaluate your final code- state how well it meets the core task?  How would you improve it?
  8. Put all of the above in your scratch code or as directed by your teacher
  9. Save all your work with your name and task, i.e. "Johnny_B_Pong.sb2"


Examplar Code:

Pong Game Starter + Wii buttons & LEDs


Video Tutorial:


5.2. Inventor Example & Tutorial 2

Inventor Example & Tutorial 2