Archive | May 2015

End of Year Arduino Projects

I took a big risk this year and decided to offer an Electronics class. I chose to teach it while I was still new to the Arduino platform and had a lot to learn about it myself… but I had the opportunity to purchase a class set of Sparkfun Inventor’s Kits, and I inherited a Computer Applications class with 23 students in it. I told my administrator at the time I was struggling with the notion of spending a semester teaching Powerpoint and Word when I had a set of Arduinos. Could I turn the class into an Electronics class instead? Although I sensed skepticism and I felt I was a little crazy, nobody told me “no”. On day 1, I told the students that even though they were signed up for Computer Applications, we’d be learning electronics – and we built the plane as it was flying. After my 2nd semester of teaching Electronics, I decided I’m keeping it. It was a great experience.

I built the whole class around Sparkfun Inventor’s Kits.

The Sparkfun Inventor's Kit, from

The Sparkfun Inventor’s Kit, from

I started by having the class do investigations using electromagnets, copper tape, resistors, voltmeters, batteries, and LED’s. We opened the SIK before mid-semester and started doing lessons from there. I used circuits from the guidebook, but I adapted them to become troubleshooting lessons or investigations instead of recipes. I generally had the students write all of their own code instead of using the example code from the kit. Since this is not a coding class per se, I focused very little on the structure of the code and instead worked with the students on troubleshooting techniques like reading the serial monitor, using a multimeter, partner coding, and trial and error.

In the end, I required a final project. The project’s requirements were:

– Must include at least one sensor
– Must use two types of output
– Must be creative
– Must document what you did with a photo, video, description, the code, and a short reflection piece
– Must collaborate with others, be inventive, and display a “maker mindset”.

Truly, I was blown away by what the students made. Their ideas were so good and they took them much farther than I could have imagined. They made:

– A light wheel that tells you a color on an LED, an LCD screen, and by turning a servo to a color when you turn a potentiometer.

The "Light Wheel"

The “Light Wheel”



– An “Electronic Birthday Cake”

It plays the birthday song, and then you turn a potentiometer to "blow out" the candles.

It plays the birthday song, and then you turn a potentiometer to “blow out” the candles.

– An “Electronic Piano” that plays color-coordinated musical notes with pushbuttons

Plays color-coded notes with each button press.

Plays color-coded notes with each button press.

– A homemade video game made using Processing and an Arduino-based controller.

The game is a little tank game that's a lot of fun.

The game is a little tank game that’s a lot of fun.

And more. They were so awesome. I’m so humbled at how quickly the students picked everything up.

I required the students to turn in enough information that it could be turned into an online tutorial, and then I copied and pasted their information into a Google Site. In the spirit of open-source innovation, if you or your students are looking for some great beginner projects, this site shows you what some determined 13-year-old kids can do.


This class taught me what it’s really like to be a “maker”. It’s amazing that we live in a time where you can come up with an idea in your head, create the circuit, design the code, 3-D print the housing and then your idea is in front of you when it was in your head not that long ago. The students were beaming with pride at what they accomplished. We presented our projects at the school’s Math Carnival and invited sixth-graders to visit the class for a special demo day. I can see this group of students carrying these skills with them for a lifetime. I’m excited to see what they make.


Pre-teaching Slope with Scratch

I gave my 6th graders a challenge in Scratch today and loved the potential to build background on slope as they go into algebra classes later.

This is a starter program in which a cat uses the pen tools to draw a set of stairs to reach a princess.

Using the pen tools so the cat can reach his friend princess using stairs.

Using the pen tools so the cat can reach his friend princess using stairs.

The instructions are:

The cat asks you for the height and width of each step. It should draw an entire set of steps using a loop. Test to see if the cat reaches the princess. Can you guess a height and width for the steps that will reach the princess exactly?

I loved watching the students interact with the project. There were several different solutions that came out, and several different misconceptions. It was fairly common for students to plug random “move” blocks into a loop and test it without really analyzing why they were doing what they did. Getting the students to think through the sequence that needed to be repeated was challenging. Move up. Up how much? then turn. Move right. right how much? turn. Repeat.  Some students used a move-turn-move-turn sequence and others figured out it took fewer blocks if you used change x – change y.  Some tried to work with “glide” blocks, but since they had trouble thinking through the math of the new coordinates, nobody completed it.

Once they created the steps, they tried to figure out how to get the cat on a collision course with the princess. It was fascinating. It was very common for students to try height = 10, width = 10. The cat would travel at a 45 degree angle and end up above the princess. So they would try height = 20, width = 20. When that didn’t work, height = 50, width = 50. At this point, many would start to try entering different values for the height and width. If the height is greater than the width, the cat overshoots the princess even more. But if the height is anywhere from two-fifths to three-fifths of the width, the cat would collide with the princess. A ratio of 5/12 works. 20/30 just barely misses. 10/20 works. 6/10 works but just barely. 8/10 does not work.  Through trial and error, students figured out a height and width for the steps that reaches the princess.

I thought about how this experience might be useful prior to the students’ learning about slope. I had forgotten that Common Core doesn’t emphasize the rise/run ratio as a method for teaching slope, but focuses on unit rates:

Construct a function to model a linear relationship between two quantities. Determine the rate of change  and initial value of the function from a description of a relationship or from two (x, y) values, including reading these from a table or from a graph. Interpret the rate of change and initial value of a linear function in terms of the situation it models, and in terms of its graph or a table of values.

Here you see the ratio understanding coming out in 8th grade, but the ideas around ratios build all the way through middle school.

Use similar triangles to explain why the slope m is the same between any two distinct points on a non-vertical line in the coordinate plane; derive the equation y = mx for a line through the origin and the equation y = mx + b for a line intercepting the vertical axis at b.


I would love to have the students gather data on what height and width were needed to get the cat to the princess and make some inferences about the relationship between height, width, and coordinates. From there, wouldn’t it be interesting to modify the activity such that the cat and princess start at random locations each time and you need to calculate the height and width of the stairs?

An additional layer of challenge would be to limit the students to only using the “move to x: y:” and “glide to x: y:” blocks – so they have do to the math on the x and y coordinates for the stairs. It’s interesting how working with addition and subtraction as motion in the coordinate plane really expands your knowledge of those operations – we work so often with the idea of “put together” and “take away” that we forget they can represent vectors of motion.




So was I an effective teacher?

We just finished with PARCC testing for the year. Oh my gosh, finally. It was a massive effort involving time and technology and a ton of flexibility and creative problem-solving. For eight school days, I had to teach my computer classes either with no computers or with only a half hour of class time. The tests were really long and tiring and we were fried at the end of each session. I spent a lot of money on cookies and gum to keep the kids’ spirits up. Eight full days of testing schedules. I wondered to myself if the information I’m going to get from PARCC tests is so amazing that it would be well worth the eight days of testing.

So I put forth a little experiment. In the past few years, we have given two standardized math assessments. We give NWEA MAP, which is an hour-long multiple-choice test you can administer anytime on a flexible schedule. It’s easy and you get results right away. I’ve always valued being able to show a kid just how many points she gained in one year, on the day we take the test.

The other assessment has been (up until we started with PARCC) our state assessment, aligned to the Colorado Academic Standards (now Common Core). The test is called TCAP and takes 5-6 hours to administer for math alone. I bet myself that the data from the 1-hour test was just as good as the data from the 6 hour test. I decided I would scatterplot my growth on MAP vs. the growth on TCAP. If the correlation was strong, we were getting good information from both tests, and maybe that’s evidence we could get by with just one of them. You with me?

Growth is ultimately what determines our school’s rating and my rating as a teacher. I’ve always been behind that model, because it doesn’t matter where your kids start at the beginning of the year. If they grow, you’ve taught them, and that’s good. My understanding is that my results from the two standardized tests – MAP and TCAP – are plugged into a formula to give me an Effectiveness Rating.

So. Growth on MAP versus growth on TCAP.  For the MAP tests, I see the numbers right away, so I get a raw score in points and just subtract the two spring scores to find the growth. Typical growth is around 6 points.  For TCAP, the state uses a “growth model” formula to determine growth from year to year, and then they tell us a child’s growth percentile. Thus, typical growth is in the 50th percentile.

The graph:


I used the correl() function in Excel to find the correlation coefficient. It’s 0.24. If there is a correlation, it’s really weak.

This is the data that was used to determine my effectiveness rating. Would you determine that I did an effective job?

I made a graph of the previous year’s data and found the same thing. Growth by one measure did not predict growth by another. I took my charts to my friend Kathy to show her. She just as nerdy as I am about data, and she gets just as intense about results, so I knew she’d be really interested in it.

Me: So I was curious if growth on MAP had anything to do with growth on TCAP, since they’re used for our effectiveness rating. So I scatterplotted MAP against TCAP growth model.

Kathy: They don’t correlate.

Me: Wha… how did you know?

Kathy: I’ve been plotting mine for four years. My students analyze it as a statistics activity. There is no correlation between their MAP growth and TCAP growth.

Me: I’m having a crisis over this. It always meant a lot to me to get my test results.

Kathy: Maybe it’s just you and me. We ought to look at it department-wide.

So I took my charts to one of my administrators and explained what I found.

Me: So there’s no correlation.

Admin: Really?

Me: Look, there’s the correlation coefficient.

Admin: They’re testing different things.

Me: They shouldn’t be testing different things. Right? They should be measuring your growth in math achievement.

Admin: If they’re testing different things, we have to make sure we’re not treating them as if they’re testing the same thing. I’ll show this to the assessment department head. Will you send it to me electronically?

I have always appreciated that the leadership at my school and my district wants to use data correctly as an improvement tool, and they always welcome a critical discussion. I love that we can have that conversation.

He’s right, the tests probably are measuring different things, but I honestly do not know what they each measure. There are some key differences in the tests. MAP is all multiple choice, TCAP is partly constructed response and graded with a rubric. MAP is computerized. TCAP has always been on paper. MAP is a general survey of math knowledge and problem-solving, TCAP is standards-based and specific to a grade level. But still, you would think if a student generally got smarter in math, they would consistently show growth by both measures, and it just isn’t true.

I am really wondering if everything I’ve ever thought about math achievement tests is a lie.

One possibility is that PARCC will add clarity to this confusing picture of student achievement growth.

The other possibility is that I’ll get one more data point that doesn’t make any sense, but this time I will have wasted 8 days getting that data point.

Advice on a coding lesson! Credit Card debt and Loops

As my students were learning about loops, I really wanted to add  tie-in to personal financial literacy.  My students are still very new to programming and this was their first experience with “for” loops. I am struggling with the right amount of structure for this task and would love your help reflecting on it.

Relevant standards:

7th grade Expressions and Equations: Multi-step ratio and proportion problems
Solve multi-step real-life and mathematical problems posed with positive and negative rational numbers in any form (whole numbers, fractions, and decimals), using tools strategically. Apply properties of operations to calculate with numbers in any form; convert between forms as appropriate; and assess the reasonableness of answers using mental computation and estimation strategies.

High School Functions: Exponential Growth
Observe using graphs and tables that a quantity increasing exponentially eventually exceeds a quantity increasing linearly, quadratically, or (more generally) as a polynomial function.

Computer Science Teachers Association: Middle School
Implement problem solutions using a programming language, including: looping behavior, conditional statements, logic, expressions, variables, and functions.

I gave the students this problem situation.

Fresh out of college, you need to buy furniture for your new apartment. You’re able to get a credit card with a 15% Annual Percentage Rate (APR). You immediately charge $5000 to the credit card for your new accessories for the crib.

The minimum payment on the credit card is $25, which you pay faithfully every month.
The credit card company charges you 1/12 of the APR every month on whatever money is left on the card.

Write a program that will calculate how much you have left to pay after 36 months.

From here, I have choices.

1) I can give students the pseudocode, and have them write the code.

Use variables for:
amount of debt, 
monthly payment,
number of months,
Repeat this loop for the number of months:
 Subtract the monthly payment from the debt.
 Add the fee to the debt (1/12 of the APR * the debt)

At the end, show how much debt is left.

2) I can give them skeleton code to fill in.

var debt = 5000;
var apr = 0.15;
var payment = 25;
var months = 36;
// complete
println( );
for(var i = 0;i<months; i+=1)
 // add code and finish println statement
 println( );
// complete
println( );

3) I can have them enter the “canned” code and then modify it to answer the key questions.

var debt = 5000;
var apr = 0.15;
var payment = 25;
var months = 36;

println("In the beginning you owed: $" + debt);

for(var i = 0;i<months; i+=1)
 println("At the start of month " + i + " you have $" +debt + " in debt");
 debt = debt - payment;
 debt = debt + (apr / 12 * debt);

println("At the end you have $" + debt + " in debt.");

Here are the questions.
How much will you have to pay each month to pay off the credit card in 36 months?

Modify the program so it prints a message when the card is paid off.

Create and answer other questions with this simulation. Note your questions and what the answers are.

Since this was a new programming structure, I went with option 3. I loved the conversation I had with the students and the interesting questions they asked – but I have been wondering if I should have gone with less scaffolding so they could problem-solve themselves.  Always such a tough call when learning something new. What would you have done?

Looping Lessons!

My 7th and 8th grade computer science students are done now with their programming unit and on to final projects!  In their programming unit, I focused hard on one particular standard in the CSTA standards:

CPP:L2:5  Implement problem solutions using a programming language, including: looping behavior, conditional statements, logic, expressions, variables, and functions.

I really think my students grew a ton in all of these areas this year. Looping was the last of these I taught. This is the sequence of lessons I used.

1) Khan Academy looping lessons:  I asked them to watch the video lesson, take the quiz, and do the “Loopy Ruler” challenge.

2) Review of While Loops and Matching challenge. We did a group discussion reviewing the structure of the loop – the initialization, the boolean expression, the iteration, and the behavior of variables. We talked about infinite loops and then I paired the kids up, cut up this set of cards, and had them match programs to outputs. We had a whole-group discussion afterward about why they made the matches they did, and any matches that were difficult to make.

3) Geometric pattern activity. Students created a program that made a drawing that used loops to make it repetitive, similar to this one.

4) Loop warmup.  Students got a partner and were asked to write code for 3 loops:  One that would run forever, one that would run exactly 5 times, and a third that would never run.  I had students share their answers on the board and discuss why they worked (or didn’t).

5) While loop quiz.  This was a really, really difficult assignment and I ended up having to abort it early.  I think it’s a great thinking activity, though, and I want to figure out how to make it work better. The prompt is this:

The line(x1,y1,x2,y2); command draws a line from x1,y1 to x2,y2. For example, line(50,70,100,130); draws a line from (50,70) to (100,130).

For this task, you will use a while loop to draw a staircase on the canvas. You should have four variables: x, y, w, and h. x,y specify the starting position of the first step. w, h specify the width and height of the stairs. Your program should have ONLY two line() commands and use a while loop to repeat them to draw the staircase.

var x = 0;
var y = 0;
var w = 70;
var h = 50;

This should draw a staircase that starts at (0,0) and each step is 70 units wide and 50 units tall.

A correct implementation looks like this:

And I had a couple of students that nailed it right away, and 85% of the class that struggled, and struggled, and struggled. Some made things that looked like steps but had no loops. Others did not use the variables. Many hard-coded a single step and then did not know what to do.  For me, the math on the variables is a really straightforward thing, but for the students, this was such a weird representation of slope and addition that it just really blew their minds. I ended up helping a lot.

6) Credit Card simulation.  I introduced “for” loops with this document and program on how credit cards work.

Presentation: forloops_pdf

Credit Card simulation

I love the credit card activity for the conversation it brings about with the students. They really aren’t taught what a credit card is or what the term APR means or what you’re getting into when you swipe your card. The scenario of making payments faithfully every month, and still ending up deeply in debt, is really common and I think the simulation is powerful. I feel like I’m still looking for great prompts / tasks around this scenario to make it the activity it really could be. I would so love feedback on that and may write about it separately!

7) Debate on “for” loops vs. “while” loops. Why should we use one over the other?  Which do you prefer?  Funny how passionate students get over this topic. 🙂


Stuffing Sacks – a coding solution

Back in April, I was being nosy on Twitter and noticed a conversation between a couple of math teachers I follow. Sam J. Shah blogged about an interesting math problem they were trying to solve. The problem goes something like this.

When I go to the grocery store, I come back with a lot of plastic bags.
I stuff them inside each other when I get home. I stuff them until they’re all inside the last bag.
There are 2 ways I can stuff 3 bags. I could stuff one bag into another, then stuff both into the third bag.
Or, I could stuff the first two bags side-by-side into the third bag.
How many ways can I stuff TEN bags?

It’s a really beautiful problem, and I can tell because it ate at me for a whole month and here I am still thinking about it.  After a few fits and starts, I could tell it had a recursive nature to it.

I started by counting all of the possibilities. Once I got to 5 and 6 bags, you can see some patterns.

Here are all the ways you can stuff 5 bags.


Abstracting this a little, I turned the drawings into trees instead of bags. The connector means “contains”. The last abstraction shows how many bags are stuffed into the “sub-stuff”.  For example, the first big bag contains 1,1,1,1 sub-stuffs. The last two bags on the right have one big bag with a 3,1 sub-stuff. Since there are two ways to stuff 3 bags and 1 way to stuff 1 bag, there are 2 ways to stuff a (3,1) sub-stuff.


You can see the beginnings of a formula emerging.


wts stands for “ways to stuff. To figure out the number of ways to stuff 5 bags, you need to know how many ways there are to stuff 4, 3, 2, and 1 bag. The fifth bag can contain 4 sub-stuffs (4 ways to stuff) or 3 + 1 sub-stuffs (2 ways * 1 way) or 2 + 2 sub-stuffs (1 way * 1 way) or 2 + 1 + 1 sub-stuffs (1*1*1) or 1+1+1+1 sub-stuffs (1*1*1*1). Add them all up and that is 9 ways to stuff the 5 bags.

So I wrote this program to emulate the problem and count all of the ways to stuff “n” bags. I was really proud of it and thought I had it working just great.

The Bag Problem Program on Khan Academy

I worked really hard on it. There is an array inside one of the objects pre-populated with [1,1,1,2]. There is 1 way to stuff 0 bags. 1 way to stuff 1 bag. 1 way to stuff 2 bags. 2 ways to stuff 3 bags. After this, it follows the algorithm I mentioned above. When the program calculates the number of ways to stuff a new type of bag, it’s added to the array.

It’s a dreadful program to understand. The BigBagStuffer contains BagStuffers. Each BagStuffer contains a decomposition of the BigBagStuffer – it has the sub-stuffs. For example, you can stuff 7 bags by stuffing the 6 remaining bags inside a seventh. Those 6 bags can be arranged (6), (5,1), (4,2), (3,3), (4, 1, 1), and every way there is to add whole numbers to get 6.

The BagStuffer constructor finds all decompositions of a number of length “len”. BagStuffer (6,3) for example contains all ways to stuff 6 bags in a sequence of 3 numbers. It will contain all the ways to stuff (4, 1, 1), (3, 2, 1), and the (2, 2, 2) bags.

The arrCompare() utility function is there to identify unique decompositions.  The (2, 1, 1) is the same as the (1, 1, 2) stuff, so the second one is never added to the list.

The math to calculate the number of ways to stuff the bags is on lines 160 through 173.

I thought it was really good and solid and it produces this sequence.

1, 1, 2, 4, 9, 20, 49, 117, 297, 746.

Right about this time, I was checking Sam’s blog again and noticed this link come up.

It describes a problem of identifying the number of unique rooted trees that can be made with “n” nodes. This problem can be modeled as a rooted tree. A bag stuff can be shown as a tree with one root and branches demonstrating the relationship “contains”. This web page above shows the actual sequence of “stuffs” is not what I thought, but it’s this.

1, 1, 2, 4, 9, 20, 48, 115, 286, 719

So I’m overcounting, but how? The method is really sound.

Since 7 bags is the place where I overcounted, I went through the work of drawing out – using rooted trees – every single way to stuff 7 bags. I wanted to see how the overcounting happened.


Not seeing any duplicates yet. But then I found them.


These are all the ways you can stuff 6 bags into a seventh, where you stuff them as (3,3). My algorithm would have shown there are 4 ways to stuff these bags, because there are 2 ways to stuff 3 bags and 2*2 = 4. However, if you look, the 2nd and 4th ways are duplicates and I should have only counted one of them.

I inferred that anytime you have a sub-stuff with a duplicate in the sequence (such as (4,4) or (3,3,1) or (5,5,2)) you will need to count only unique stuffs and not multiply all the ways together as I was doing before.

So how many unique stuffs are there when you have duplicates?  I was further confused when I realized that some stuffs will have 3 or more dimensions of duplicates, such as (3,3,3) or (4,4,4).  There are 4 ways to stuff 4 bags, but the number of ways to stuff a bag containing 4 stuffs and 4 stuffs and 4 stuffs is not 4x4x4. You have to eliminate the duplicates.

I played with different algorithms for finding the unique stuffs when you have duplicates. This is similar in structure to a dominoes counting problem. How many unique dominoes are in a box?  Extend it to “n” dimensional dominoes.

I made a spreadsheet showing this work. It’s messy but I sort of love it for that reason.

SPREADSHEET for counting unique trees

The algorithm is shown in the numUniqueTrees() function in my final code. numUniqueTrees() takes two parameters, the number of ways to stuff the bags and the number of duplicates that appear. So if you had a 13-bag containing a (6,6) sub-stuff, the number of unique combinations therein would be given by numUniqueTrees(20,2).

My final “Baggies” program calculates the number of ways to stuff “n” grocery bags and eliminates the duplicates causing the error in counting. This one gives me the sequence shown in the proper link, but it breaks down somewhere in the high teens due to the recursion – I’m overflowing whatever memory Khan Academy’s little environment gives me. 🙂

BAGGIES PROGRAM – final version.


Made using: Khan Academy Computer Science.

My code is horribly messy. If I inherited this code from someone else and had to maintain it, I’d be bitter. It’s still so exciting to me because of that sense of “flow” I had as I wrote it. Recursion is head-splitting. I had to plan hard for some of it and some of it just sailed off the keyboard as I coded, and I loved that feeling.

Thanks to Sam and Matt Enlow for a really fun problem-solving experience!

Reflecting, hiking out of the valley, moving on.

I wrote last time about how much I struggled with a hardware lesson with my students. Isn’t it hard to go back into the classroom the next day?  The relationship you had with your students is changed after that point. Respect is lost, trust is damaged, and the hard work of rebuilding begins.

I started by blanking the screens of the students. I went through this presentation. I talked, and they listened.

This slideshow requires JavaScript.

Students filled out an anonymous form then, letting me know what they observed during the lesson, what their part was in the lesson, and their advice on how to meet the learning objectives.

I crunched the data and showed the results to them next class.

Chart 1: What did you do? What did you observe others doing?



There were unusually high numbers of “Others were not safe” and “others were not learning”. However there were also high numbers of “I was safe” and “I tried to learn”. I do believe the respondents were being honest with me.  I pointed out the safety issues were noticeable and bothersome to a large proportion of he class – but that it seemed to be a minority of the class that was being unsafe and not listening.

Chart 2: What should we do?


The most popular result was “Do an assignment at home”. Some students made suggestions for what the assignment should be: watch a video and take notes, read articles, go over flash cards, or look through pictures. The next most popular suggestions were “do some research as a group” and “take a test”.

I told the students I liked the “assignment at home” idea. I assigned two web links on how to take apart a computer, and asked the students to review them.

How to take apart a computer:

How to disassemble a laptop:

Then I created a ten-question quiz. Some of the questions can be answered from information on the websites, and other information may need to be searched online.  It’s all multiple choice and I’ll grade it with Flubaroo.

Here’s what I learned from the experience.

1) The online instructables were helpful to me and I wish I had arranged for those to be pre-work before doing the actual dissection. Pre-work before a tough activity like that is very important for setting up a successful structure later.

2) I knew, on some level, that I had students in that particular class that were going to struggle with maturity and decision making. I took a risk, and sometimes those work out and sometimes they don’t. I didn’t do everything right, but even if I had, it would have still been a risk.  And you know what? Maybe I was right to do it anyway. I need to be able to release responsibility to them eventually and can’t run every activity under the assumption that I can’t trust my students. Sometimes I have to let them try, even if that means sometimes they are going to fail. In the future, I might not dissect as many computers. I will structure the pre-work more, I will create larger, more accountable groups, I may do some of the work for them and let the students know which parts they’re allowed to do, I may ration tools. But I’ll still take some risks and still get bitten sometimes.

3) I did get some feedback from students in that class saying they loved the activity and they learned a lot from it. They had never seen the inside of a computer before. They didn’t know the difference between a video card and a CPU before. They thanked me for allowing them to do it. Even when a lesson seems like a disaster from my perspective, it helps to ask the students for theirs because you find successes where you didn’t expect it. You can build from there.

Thank you all for your support. Onward.


Hardware Week and a Valley.

For my 7th and 8th grade CS classes, I set a goal to help students develop a basic understanding of computer hardware and architecture. Early in the year we did lessons on binary and hexadecimal information, the internet and how information is divided into packets and transmitted through data centers. I have had “Hardware Week” once a semester to celebrate the stuff that actually goes into a computer.

One activity for Hardware Week is a computer dissection! I ask for donations from parents, and it’s amazing how many have old computers they’re willing to donate for “science”. I give the students tools and a safety talk, and allow them to open the computer, see what’s inside, sort the parts, label them, and do some research about them.

The parts can generally be sorted into 6 subsystems:

Processor (generally just the main CPU, which is usually removable, big and square, with lots of pins)

Short-term storage (the RAM, usually removable)

Long-term storage (things like the hard drive, CD-ROM, sometimes even floppies)

I/O (anything from a USB port to the keyboard, monitor, wifi card, ethernet card, video card)

Power (batteries or AC/DC power supply)

Heat (fans, heat sinks)

Last semester, I had the kids create posters about their computers and we did a little museum walk.

Posters that go along with labeled parts for a museum walk of dissected computers.

Posters that go along with labeled parts for a museum walk of dissected computers.

This year, I had the students create a Google presentation, set their parts out around their slide presentation, and do a museum walk of others’ computers. It was really cool. The kids loved it and had some great aha moments. Awesome conversations, tons of curiosity, and for the most part, it met the goal of helping students understand computer hardware and how it fits into system architecture.

Someone built this computer with love. It had an AMD K6 processor and a good old Sound Blaster audio card. A real treasure!

Someone built this computer with love. It had an AMD K6 processor and a good old Sound Blaster audio card. A real treasure!

Laptops are interesting to dissect. Everything is smaller and a little harder to access. The cooling system is tinier and more intricate. That shiny film was behind the LCD screen. How does THAT work?

Laptops are interesting to dissect. Everything is smaller and a little harder to access. The cooling system is tinier and more intricate. That shiny film was behind the LCD screen. How does THAT work?

Cute, right? I had so much fun with this group of kids and I was just as engaged as they were.

Things were really going well until I taught my 5th period class, and then I hit my valley. The students in that class didn’t handle the responsibility of dissecting a computer well at all.

Students damaged my pliers and screwdrivers trying to brute-force computers open.
They pounded, stomped, and shattered long past the point of dissection.
They destroyed a couple of chassis completely.
They broke motherboards in half.
We had a few gashes in hands.
One group tried to puncture a lithium battery.
One group shattered the glass inside what I think was a CD burner, and got glass on the floor.
One group used screwdrivers to pry all of the chips, capacitors, and resistors off the motherboard, stomped on the board, and left it on the floor.
A student in the same group treated the power supply similarly.
They argued over which parts they would get to take home as souvenirs instead of analyzing their work.

It was really stressful. I had envisioned walking around with my clipboard, marking observations and answering student questions about their natural curiosity as they carefully removed and labeled parts – much like things in my other class. It didn’t go that way and was really stressful. I called a couple of students back from their 6th period classes and made them clean up. They flat-out denied they made the messes, even though I witnessed the destruction first hand. At the end of class, a solid-state hard drive went missing, one that I promised its donor I would recycle.
Only two groups made any progress at all on their presentations, and not one student looked around the classroom and helped to clean it up at the end of class.

I went home and I talked it out with supportive friends, had a glass of wine and cried a little, felt like a horrible teacher all weekend. Having your second-to-last class of the week go down like that will mess with your psyche. I saw one of the parents at a school function and she told me how stressed her son was that he would get a bad grade. I also got this e-mail from another student.

Functions, and More Functions

Hello everyone! I am sharing my lessons for introducing functions with middle school students. I have been out of the classroom an awful lot during April, so this has meant I often had to leave video lessons when I might have preferred having the students do inquiry. There’s a lot more that could be done to turn these lessons into rich tasks. I hope you share what you do with them!

The concept of a function in computer science is similar to, but not completely identical to, the function you learn about in math class.

In mathematics, a function is a rule you apply to one or more inputs. You get exactly one unique output.

In computer science, a function is a rule you apply to ZERO or more inputs. You can get no outputs or any output you want from a single unique number to a boolean value to a text string to an entire data structure.

In general, the reason you use a function in computer science is to make a chunk of code re-usable. For example, if you’re creating a video game, you might have 100 lines of code that render a character in your game. Instead of copying and pasting the 100 lines each time you draw the character, you can simply write:


and your main character will appear at coordinates (x,y) on the screen.

This year, I used an awful lot of direct instruction to teach students about functions. I would have liked to make it more inquiry based. 1) I don’t fully know how yet and 2) I’ve been out of the classroom enough that I had to make flipped lessons that could be used as sub plans. This is what I did.

Day 1: Introduction to Functions. I had my students start with this program here, which draws a simple cat face with 23 or so lines of code.

I have them turn it into a program that draws a kitty, then one that draws a kitty at a random location, and then one that draws a kitty at a random location with a specified head size.

Students figure out from each other how to add random coloring of the kitty, and then how to make lots and lots of them. If I have a class in which kids have already done some Khan Academy programming lessons, often they’ll know how to use the draw() loop to animate lots of kitties, and productive chaos ensues as they teach each other how to do this. Programming suddenly starts to become really fun.

I have always struggled with the “I-do / You-do / We all do” mode of teaching students how to do something. And when I’m teaching a new programming structure, sometimes there is just something to typing in a canned program.

Day 2: Special functions. A common paradigm for video game programming is to have functions that are set up to run as infinite loops. In many environments, you’ll see an update() and a draw() function. These run over and over and over again, many frames per second. The functions change variables in your game and then re-draw the screen according to the information in the variables. Part of the work of game design is figuring out what information you have to manage and change each frame. I start on functions before I even do loops because you get so much reward out of the built-in animation and interactive-ness brought to you through these functions.

In Khan Academy, a couple of special functions are:

var draw = function()

This function will execute about 60 times per second. It’s the main animation loop in the Processing language, which this JavaScript implementation uses. You use it to update variables and then re-draw your screen. draw() takes no inputs and has no outputs.

var mouseClicked = function()

This special function is executed anytime the mouse button is clicked (that is, pressed and then released). Again, there are no inputs and no outputs.

In both of these functions, you can make use of special variables: mouseX and mouseY. These variables, at any point in your program, contain the x and y coordinates of your mouse.

I chose to use a little video lesson to introduce the purposes of these functions by animating a little stick man.

Here is the starter that simply draws a stickman.


Day 3: Gravity and Bouncing

Once students learn how to animate the stickman, they’re always interested in learning how to make the character bounce, or how to add a gravity jump! In this task, as with many computer science tasks, the challenge is not in how to implement it but how to plan it. You need to understand what variables you’re working with and how they change with each frame of the animation.

What do I normally do when I plan an animation? I consider the rules that govern the movement of the characters. What changes? What mathematical rules decide the change?

I gave the students a planning sheet with a crude 400×400 coordinate grid (remember, 0,0 is in the upper left) and a T-chart. With the t-chart, they could plan the position of a bouncing character.

The x-coordinate and the change in the x coordinate both need to be variables.

The x-coordinate and the change in the x coordinate both need to be variables.

The T-chart shows that the x-coordinate is changing by adding 20 to its value up until it reaches the coordinate 400, and then it changes by adding -20. The x-coordinate and the speed both need to be variables, and the rule for changing the speed from positive to negative is that when the x-coordinate is greater than or equal to 400, the xspeed value is changed by multiplying it by -1.

All of this functionality goes in the draw() function that runs over and over again, at about 60 frames per second.

The same logic can be applied to the y-coordinate. The final result is here, and it uses two functions: stickman() and draw().

Stickman Bounce Program

Then we got to planning for a gravity jump. In a gravity jump, your stickman makes a parabola shape, which some students had already learned about a little in Algebra II.  You can plan for the motion using a graph and a T-chart.

By the way, I really do this when I am planning an animation. Most of it is done in my head at this point, but when I was an early programmer, I did a lot of this type of sketching out and planning.

The x-coordinate changes linearly, but the y-coordinate has a different pattern.

The x-coordinate changes linearly, but the y-coordinate has a different pattern.

In this case, the x-coordinate goes up in a linear fashion but the y-coordinate change is more interesting. The y-coordinate changes by a different amount every frame, but the *change* in the y-coordinate is what changes in a linear fashion.  It’ll increase by -60, then -40, then -20, and so on until it has gotten back to the y-coordinate of 360 or higher.

This is what that program looks like in action. I played with the initial speed and the force of gravity until the jump seemed a little realistic.

Stickman Gravity Jump

I made a video lesson about this process since I was absent the day the lesson was taught. I don’t think my students could reproduce it. I suppose my learning goal was for them to appreciate the planning process and to understand how to use the draw() and mouseClicked() functions in an animation.

Day 4: Function Return statements and Money Program

I had students work on the video lessons about functions in Khan Academy and learn about function return values.  They started with the first lesson and ended up at the Calculator activity. I was gone for this class (I was out so much in April!)

Their independent task was to finish this “moneyface” program.

var pennies = 1468;
var nickels = 486;
var dimes = 400;
var quarters = 361;
var dollars = 330;

var rich = totalMoney(dollars, quarters, dimes, nickels, pennies);


The code uses two functions, totalMoney() and face().  I asked for totalMoney() to take five inputs as shown, and have a return value that would be the total amount of money you have. The face() function should draw a happy face if you had more than 500 dollars, otherwise a sad face.

Some students were able to complete the task, but I could tell others were not quite there when it came to function return values. This is what the final program should look like.

MoneyFace Program


Day 5: Matching Activity and finish money face program

When I looked at student work, I could tell they needed more support with writing functions, so I created a matching activity. In the activity, I give them a diagram showing inputs and outputs of a function, a function definition, and a function call. They have to match the three faces of a function together.  This Google Doc shows the matches side by side.  I cut the document up into cards and gave each team a set of cards.

Function Matching Cards

This activity was engaging and challenging and it really went very well. Many students told me they really felt they understood functions a lot better, so it was a helpful activity. Afterward, I helped different groups finish their “money face” program while the ones who were done were able to start watching videos on While loops.

If I did this unit again, I would have brought out the matching activity a lot sooner and would have really restructured the gravity and bouncing activities. I know the students *saw* how I interact with planning an animation, but I don’t think it helped them plan an animation. You learn these things as you need them, and the need wasn’t really there for the students.  If they didn’t come into the activity with a curiosity about how it worked, the activity wasn’t going to stick. Next year I’ll decouple the bouncing and gravity math from the learning of functions and work on it during the final project time.