Using PicoCrickets to Teach Debugging

P.I.C.O. Cricket program for a purring catWe ran into trouble yesterday trying to make a cat meow when left in the dark. The cat was a PicoCricket, a programmable kit for making creations that move, make sounds, and light up based on inputs like touch, sound, and light. We were trying to make a cat that purrs when it’s dark, but the thing purred no matter the light conditions. I did not plan it, but it turned into a good debugging exercise for my daughters (ages 10 and 12). The image on the left shows the program with which we began, which was running in concert with a similar program (stack of blocks) to make the cat’s collar light up. (This is one of the sample projects sent with the kit.) The program on the left basically instructs as follows: "Keep doing the following: if the sensor is picking up light at a brightness of less than 20, then play the sound of a kitten." ("20" what, I am not sure.)

P.I.C.O. Cricket program with touch inputWe were not sure if the ever-present purring problem was physical or programmatic, so we checked out some of the physical things first: Cables snugly connected? Batteries strong enough? We tried swapping in a different light sensor. Next we moved on to programmatic debugging. We eliminated the additional set of blocks (program) to see if that was part of the problem. Still the cat purred as soon as we turned it on. We tried a different variable (the input of touch instead of brigthness). This time it recognized the sensor and did what we intended: It did nothing until we pressed the button on the touch sensor, at which time it purred. (I realize there’s no recognizable cat here: imagine a felt thing with ears, eyes, and whiskers with the PicoCricket parts hidden inside.)

Program using an input of dark instead of low brightnessNext we tried going back to the original program, but this time testing for "dark" instead of "brightness less than 20." Perhaps the way we were using brightness was faulty. Alas, dark also did not work: the cricket purred as soon as it was switched on.

A little debug output: display brightnessThe question of what the light sensor measures was now paramount. If we were working on a screen, I would output as much dynamically generated information as possible. This was the key. We added a "display brightness" command to the program. It turns out that the fluorescent light in our living room rates a brightness of only 3 or 4 on the display. The cat purred right away when the test was "brightness less than 20" because it was indeed less than 20. Covering the sensor with our hands, we found that "dark" is triggered by a brightness rating of 3 or lower. So the program and our sensors were working; we just needed to change the brightness test to "brightness less than 2" in order to have consistent control over when our cat purrred.

PicoCricket setup with a light sensor, digital display, and audio output piecesI loved how intrigued the kids were (both at home at at the local tween center where students I work with did an outreach activity with the PicoCrickets). The crickets were developed at the MIT Media Lab to engage young people in computing through art and storytelling. Scratch is a programming app (animation, games, art, music) from MIT that kids can download (free), create stuff with and then upload to share. Scratch uses a similar graphical interface with snapping blocks like the ones seen on this page. Storytelling Alice (from Carnegie Mellon student Caitlin Kelleher) is a "programming environment designed to motivate a broad spectrum of middle school students (particularly girls) to learn to program computers through creating short 3D animated movies." The National Center for Women in IT (NCWIT) offers Outreach in a Box kits to help people get started doing small outreach projects to get young girls interested in computing. Time to do some outreach!

Submit a Comment

You must be logged in to post a comment.