Scratching the surface
I taught a 10 week course in introductory programming in Scratch with a combined year 9 and 10 class – would welcome comments please.
My aim was to follow the syllabus (of course!) but mainly to
- develop an approach to problem solving
- develop an appreciation of logic
- demonstrate that Maths has an application
- build a foundation for Robotics and Artificial Intelligence as the next topics to be studied
Well, sort of. Initially, the boys in particular, saw Scratch as a plaything. It couldn’t do anything really powerful and whay can’t we use a “real” programming language, ‘cos that’s what coders do.
Fair point, so we looked at a bit of code in both python and java and it became clear that problem solving and logic were missing in the students as were the concepts of loops and variables, let alone recursion.
Scratch (and it’s cousin SNAP) is perfect for this: it allows the programmer to develop really powerful code really easily. We decided to refer to Scratch as a “rapid prototyping tool” so you could test ideas quickly without debugging missing semi colons at the end of lines of code.
For the problem solving stuff, I wanted an understanding of looking at the big picture, breaking this to little bits and solving each, looking for reusable code (including looking at others’ ideas on the MIT website and using them) and chunking it all back together again.
We started simply, by modifying an existing program (pong) by changing one thing and seeing what happened (another tenet of the problem solving process)
We then deployed Picoboards which convert resistance to a value between 0 and 100. The varying resistance can be supplied by a touch switch (0 or 100), a light sensor (light dependent resistor), audio sensor (microphone) or a slider (potentiometer) as well as four independent channels that you can connect anything to.
We needed a bit of time to understand the idea of resistance (really excavating from dormant memories; they did this in Science, but knowledge derived in another subject is not accessible in our siloed curriculm – sigh)
We needed more time to convert the 1 to 100 scale of the resistor to the -250 to +250 scale of the screen so that the slider could emulate a pong bat being moved horizontally across the screen.
They all knew how to add and subtract, and how to multiply and divide, but the reason for these operations was relegated to how much change they could expect from a shopping transaction; there was no concept of translating or transforming numbers.
This is why I think Scratch should be compulsory in every junior Maths course. At least then we’d be teaching Maths, not arithmetic. But, I digress…
Trial and error (another problem solving tool) with a bit of educated guessing (that became more educated as we went along) led us to this:
if 0 to 100 on the slider has to be changed to give -250 to +250 on the screen, then 0 on the slider should be -250, 50 on the slider should give 0 and 100 should give +250.
What can we do to make that happen? (I’ll leave you to work it out, but it does involve more than one operation)
Now, we only had a few Picoboards, so we had to come up with a better solution otherwise the kids couldn’t do any more homework!
Scratch has variables, the value of which can be shown on screen with an associated on screen slider which we can set to give values between 0 and 100. Magic – now we have removed the need for gear, but we’ve also learned the idea of a variable without teaching it expressly. Magicker!
Some more experimentation: make the resistance play a note so that we can get a sliding scale as we move the slider, a bit like a voilin or fretless bass.
Easy – do the same sort of translation to convert the numbers coming from the slider, but let’s help the user and make it more like a regular guitar so that getting the slider in the zone (usually defined by the fret) gives the correct note.
Can we get the slider to play a scale in the key of C?
Now, here’s the kicker: only things that have a functional relationship can be mathematically manipulated by the translation and transforming process above.
The key of C goes 60, 62, 65, 70, 72, 75, 77, 80
Note that there is not a uniform gap between members of this series, so a linear 1 to 100 scale can’t be converted (there is a relation between the two series, but not a functional relationship – oops, sorry more maths)
So we’ll need some sort of table where the 0 to 100 of the slider is broken to 8 segments and if the slider is in any of these it looks up the number in the scale list.
Scratch provides lists (simple arrays) and they are easy to populate, but this concept took a long time to grasp.
Stuff my class learned
Now we have flowcharts, intrinsic documentation, loops, “costumes” for sprites (I haven’t specifically addressed these here), knowledge of the screen geometry, transforms and translations, variables and lists.
Not bad for a few weeks’ work.