1

I understand this may sound like a weird question, but bear with me here, OK?

I'm getting ready to teach some kids introductory computer programming. We're going to use Scratch, a drag-and-drop "brick-based" language designed by MIT.

Now, scripts in Scratch are comparable to LEGO structures. Each script needs a base, and pieces to build it up. So far, so good.

However, scripts can also contain conditionals and loops, both of which accept a sub-structure.

I would like to show my students a LEGO structure that is comparable to a Scratch script. How could i do something like conditionals and loops?

Scimonster
  • 293
  • 1
  • 11

2 Answers2

2

A conditional can perhaps be represented by a door that can be blocked from the other side, or maybe two doors, of which only one is blocked via a sliding brick.

As for loops, I would represent them as conditionals with counters, by blocking a door with a set number of bricks and removing one brick per iteration. If you'd rather count upwards, then a fixed size hole can be filled with bricks gradually.

These analogies were made to the "minifig walking through a set of corridors - the program" analogy, but we could surely find solutions for axles and gears or even pneumatics if you were thinking along those lines.

zovits
  • 16,181
  • 1
  • 41
  • 80
  • I was thinking more along the lines of "this building is like a script", but your ideas seem to work with that as well. – Scimonster Oct 22 '14 at 19:37
  • @Scimonster If the answer was useful for you, please consider accepting it, unless there is some information you still wait for, in which case I'll be happy to amend it. – zovits Oct 31 '14 at 10:49
  • I'm just waiting to verify that this works. I will be holding the class next week, and will try it out then. – Scimonster Oct 31 '14 at 10:50
  • In the end the kids were able to understand without the LEGOs, but you had a good method anyways. I might use it next time. :) – Scimonster Nov 05 '14 at 15:18
1

Based on the image on the Scratch home page, I would simply wrap the substructure in a single color, which represents the loop.

For example:

 ______
|_Loop_|__
|__|__s1__|
|__|__s2__|
|__|__s3__|
|______|

If that makes sense.

Nick2253
  • 2,220
  • 14
  • 27