I was recently tasked with creating a quick activity that could be done within a booth at the Philadelphia Science Carnival, something that would take only a few minutes to do so kids could filter in and out of the booth. It was going to be tough to do something great with that sort of timeline, and nearly impossible to stock enough supplies to support the 400+ kids that will come through during the carnival. I decided to tap my favorite ‘free’ supply, adhesive vinyl scraps from the sign shop, creating stickers on our craft plotter.
Now stickers resonate with kids in a way I don’t really understand, so I knew it would be a good draw at an event like this, but I wanted to do something less frivolous than just making worthless stickers with a craft cutting machine. So, I turned to code. We could program a cool design, and cut that out. I dove into Beetleblocks and came up with a really simple bit of code that quickly demonstrated the power of code, and the magic of math.
The code is fairly simple. First we can have students create a square, realizing that we can use the repeat block to make our lives easier. The result is this simple little chunk of code that produces a square.
Great! We have a square…but that is a pretty boring shape. Maybe we can make it interesting. Now we can start to think about some math. We know that a square is a 4 sided shape, with 90 degree angles in each corner. If we multiple the amount of sides and the angle of the corners, we get an important number: 360 degrees. What if we wanted an 8 sided shape? What would be the angles of the corners?
Great! Now we’ve learned something important, and we can really get creative with the initial shape that we draw…but a single shape is boring. Lets now create lots of these shapes, and rotate the origin of the shape a bit each time to make something a bit more interesting.
Now we’ve got something interesting! But look, we can make another interesting observation in this code. We are drawing 6 shapes within the repeat block here….each time rotating by 60 degrees. 6*60 again gives us that magic number 360! So we can create more shapes, and as long as the product of the degrees of rotation and the number of shapes equals 360 degrees.
Now that we have this code set up, we can let students play around with the numbers.
What happens if we have a 360 sided shape with 1 degree angles?
What happens if we nest yet another repeat block?
Can we use operators to automate the math for us?
Can we write our own functions like drawShape or repeatShape?
There are lots of questions that can drive further exploration. In the end, we might clean up our code using custom blocks, or add some math and variables to automate things for us.
A quick tip of note; to make the lines easier to see, we can change the display port settings in Beetleblocks. Uncheck the grid and the axis and check off ‘Parallel Projection’ to see directly down on our shapes. You can change the color of the background under the settings ‘gear’ icon, and change the color of the line with the ‘set hue to’ block under colors. You may need to zoom to fit as students start to build bigger shapes with more sides as well.
Now, the problem with this lesson is turning these thin lines into something that can be cut out into stickers, or on a laser cutter, etc. It is easy to cut these lines, simply exporting the .SVG file out of Beetleblocks. The hard part is giving those line thickness enough to create a defined shape. The easiest way I have found is importing the SVGs into Inkscape, giving the path a fairly thick stroke, and using the Stroke to Path tool.
Ultimately, this simple activity can show a great deal of coding concepts quickly. Loops, operators, variable and functions can all be explored. The connection to geometry is obvious, using degrees in an applied way can help solidify how degrees and periodic functions can be used in action.
I’d love to build on this concept to do things like laser cut jewelry, hand coded letters to create signs, continue to drive algebraic math connections while creating complex machinable 2D designs. With the focus on 3D design and 3D printing, the power of 2D line is sometime forgotten.