Category Archives: teachingCS

Raspberry Pi — the little computer that could

 

In the last few years, we’ve seen a slew of single board computers (SBC’s): Arduino, Beagle Board, Raspberry Pi…. They all have their place, and we’ll speak a bit later about what those places are. But I’m here to tell you that for all-around computer science use and mega bang-for-the-buck, you just can’t beat the Raspberry Pi.

By now, most people know about its back story, springing out of Cambridge University and a desire of their CS profs to acquaint their students with what a computer actually IS. There’s no doubt that computers are easy to use today, but that very ease of use has taken away some of the fun and excitement of learning how a computer works and how to get it to do what you want it to do. I’m totally dating myself here, but I do remember getting a Commodore 64 (cue the “backintheday” music as Grandpa regales the young’ns with tales of yesteryear). When the 64 first came out, there was a dearth of software available. But it did come with a thick spiral bound book called “Commodore Basic”. The expectation was that anyone who bought a computer would certainly want to program her own software, not just buy stuff off the shelf. And there were several magazines on the newstands that had “type-in” programs that ran several pages. I think some of it was even in assembly language! But the thinking was that computers helped you get stuff done, play games, etc., but also were things that you could use to make your own stuff.

Today, computers are a black-box technology, like a car. How does a computer work? I love asking that question and seeing the blank faces of my students! It’s easy, Mr I, you push the button! My personal favorite answer is “gypsy magic”; top points for creativity. But that doesn’t get us any closer to understanding what a computer actually is! Though it’s a wonderful fulfilment of Arthur C Clarke’s saying that any technology that we don’t understand is the same as magic. So if we can start to figure out how it works and get it to do stuff that we want it to do, then I guess we’re wizards! All right!

So this little credit-card sized, $35 computer is getting us closer to being magicians, and probably better than anything else available today. So how does it do this, exactly?

First of all, it’s not in a box. You can see the motherboard, the CPU, the traces on the board… You can plug sensors and wires into its 40 GPIO pins, which provide voltage and “channels” you can use to code attachments. And the attachments are plentiful and not too expensive, running the gamut from sensors to lights to buzzers to cameras to audio devices to… whatever! You can see both sides of the USB ports, so the mystery of the inside of the computer is laid bare.

The Raspberry Pi Foundation provides an updated OS, as well, called Raspian. It’s an offshoot of Linux (but so is the Apple OS, so don’t be scared). This OS has a modern looking GUI (graphical user interface) and comes with a host of programs that you can run right away. So it’s not too scary looking to students familiar with Windows and Apple: desktop, menus, icons, left and right clicks, etc. Pretty intuitive, we’d say. However, some tasks require digging into the terminal, a CLI (command line interface), which goes way back. And while that’s new and different to many students, it’s not impossible. Though, as I often remind them, spelling counts!

And it comes with an ever-changing assortment of free, open-source software (and that can actually be an interesting discussion. Why is this software free? Who writes and maintains it? I love seeing the students eyes widen as the catch a glimpse of an economic model that’s an alternative to individualized capitalism…). The current version as of this writing (Stretch, and yes, all of the versions of RP are named after characters in the Toy Story series. So if you had any doubts about how cool this all is….) includes the Libre Office productivity suite, Mathematica, a browser, some games, and most importantly for our purposes, a host of programming tools and environments. Scratch 1.4 and 2.0, Python 2 and 3, Java, Greenfoot. An older version of Minecraft is included FREE, and though it’s not the latest and greatest, it’s perfect for learning coding. Check out my chapter on that. And there’s even a live music coding application called Sonic Pi. While I wouldn’t use it for my everyday computer, it can do a lot that an everyday computer can’t do, like physical computing and attaching to other machines.

One thing that the Pi doesn’t have is a hard drive. In order to keep the form factor small and the cost down, they work by loading the OS (Raspian) from an SD card, which autoboots when the Pi is powered. Programs are saved to the SD card as well. So it’s a little bit of a throwback to DOS.

So what do you need to get started with RP in your classroom? Well, that $35 computer thing isn’t entirely accurate. You’ll need a few other things, but the RP people rightly figure that everybody already has a keyboard, mouse and monitor. All of these are plug and play. Latest version of the Pi has 4 USB ports and an HDMI port. You’ll also need some sort of power source, and the wall wart variety are available and usually come in a RP kit. In my classroom, I power them from power bars that have USB slots, which I’ve found preferable to having 25 wall warts to take care of. I use the power bar to power the monitor and the other computers I have in my room, which all run Windows 10.

How do you get Raspian on an SD card? Fortunately, www.raspberrypi.org has download links for the latest version, as well as instructions for how to download it and install it on an SD card. Once you put Raspian on the SD card, put the card in the Pi, and power it up, the installation software takes over, prompting you from time to time for your preferences. Don’t worry, all of the preferences can be changed from the settings menu on the Pi.

Because it’s based on Linux, which is based on Unix, which is a user-based system, the Pi requires a login. The initial default username is pi, and the password is raspberry. You should change that as soon as you can. One advantage to this is that if you have multiple students using the same Pi and the same SD card, you can set up different users so they don’t all save to the same folder. It’s not necessary but you might save yourself and your students some serious grief. I’m not sure why, but students sometimes all use the same filename when they save their Scratch game (“game” is a favorite). And if that happens, Johnny will overwrite Suzie’s Scratch “game”. Ouch.

Robots robots robots

There’s not much that can compare with the joy students get when they build and program a robot. I’m currently using 2 platforms — the Dash robot from Wonder Workshop, and NXT LEGO Mindstorms. I use the Dash in 5th grade, and the NXT in 7th grade.

What’s the attraction with robots? Well, they can move, make noises, and respond to their environment. What’s cooler than that? Not only that, but we can make them do what we want them to do, so they can become our own little minions!

The secret sauce of robotics is that we can actually watch the results of our code manifest right in front of us! We know right away if the code is right or wrong, so there’s immediate feedback. I always tell students that it’s not like other classes, where they take a quiz or test and have to wait for their teacher to grade them and get them back to you. You know right away! Not only that, but then you can modify your code and run it again. And you can do it as many times as you like in order to get it right. Yes, there’s frustration along the way when your robot doesn’t do what you want, but oh the joy when it does! Happy dance time!

Along the way, students learn something really important about robots — they’re kind of dumb. They can only do exactly what we tell them. They can’t figure out what we mean. We humans can “fill in the blanks” when others try to communicate something with us. We can infer meaning. Robots can’t, at least not yet! So that means we have to be super careful about all the instructions we give them. Welcome to computer science! As a side note, what a great training ground for middle schoolers who have organizational challenges and need to pay attention to detail! And I always tell them when they complain about how their robot is “dumb”, they’re only as smart as the instructions we give them! Ouch.

What about how many students per robot? I realize there is a range of opinion on this, and I get the importance of collaboration. However, I’m a big believer in each student having her own technology, if at all possible. There’s something to be gained from knowing that the success or failure of your robot rests entirely on you! But that may not be feasible in your situation. So work with whatever you have, but be sure that all members of the teams take ownership of the robot’s success and share the challenges as equally as possible.

So how to structure a robotics unit? My approach is to have the robots simulate a real-world series of tasks. In 5th grade, with the Dash robots, we are currently doing the “Robot Olympics”. Most of these challenges mirror Olympic events, but I’ve also taken the liberty to make up my own events. I made a 3X3 grid on the floor with duct tape or gaffer tape, which is where the events take place. Right now I’ve got Olympic tic-tac-toe, diagonal racing, curling (well, kind of), and whatever else inspires me. Teams compete and I keep a scoreboard on my whiteboard to let teams know how they’re doing. Because the Dash robots come pre-built, it’s really a matter of coding. Wonder Workshop provides 3 different platforms for coding Dash (and Dot, his less useful sidekick), and I use Blockly in 5th grade. It’s Scratch-like and fairly easy to do the dragging and dropping, making the coding the harder work. Students generally are fully engaged and love the competition. Since this is my first year of using Dash, I fully expect to build this out further. Wonder Workshop has all kinds of challenges on their site which I have yet to explore, so I anticipate continued success with this platform.

In 7th grade, I use the NXT LEGO Mindstorms platform. I realize that the EV3 has replaced the NXT, but I honestly have not seen enough compelling change in the new platform to convince me to do a wholesale switch. At some point it will happen, as the NXT bricks get harder and harder to find, but for now we’re good.

I have each student build the basic Tribot model, then add sensors as needed. I use the ultrasonic sensor first, then mix in challenges with the touch and light sensors. The sound sensor is less useful for my purposes, possibly because of the volume level of my classes (did I mention that it can get loud?). So I hardly ever use the sound sensor.

In my current iteration of challenges, I model them all after a real-life robot used in hospitals around the world called the TUG robot (built by Atheon). This robot can navigate through the hospital autonomously, avoiding obstacles and making deliveries. It can even call an elevator and choose which floor to exit at! My challenges model some of these functions. I chose the medical robot for a variety of reasons, not least of which is that it’s involved in helping people in a real way.

Some students find the building of the robot challenging, though I give them official LEGO building instructions printed out in official LEGO language (all pictures). Some students have spent much of their childhood playing with LEGO’s and are already “master builders”. Some have never connected any LEGO’s at all. Again, attention to detail is paramount. I tell them to make sure they double and triple check each part of the build, hold their robot up to the paper and be sure everything is correct. Why? In robot building, attention to detail is crucial, and if you find on step 22 that something’s wrong, you’ll have to “unbuild” your robot back to the point where you made the mistake, even if that’s on step 5! Ouch. Hard fun again.

So what does this look like in class? To be honest, sometimes it looks like complete pandemonium. Learning is messy. In one corner of the room, there are students moving a trash can in front of their robot, simulating a moving obstacle in a hospital hallway and trying to get their robot around it. In another corner, one student is helping another rebuild their robot so it works(though they have to follow my rule: don’t touch the other person’s bot!). In another corner, students are getting a mini-lesson from me on how to navigate the software and download it to the robot. On the board, I have my Help List, which determines in what order I answer questions. When students have tested their robot and know they have it working right on a particular challenge, they put their names on the Help List and excitedly demonstrate their bot meeting the challenge (or not. Sometimes it still doesn’t work, and they are back to coding and running the robot again, with some modifications on either the code or the bot). At another workstation, one student is helping another student with the code (again, following Mr I’s rule — don’t touch their keyboard or mouse), pointing to the screen and showing where their mistake is. 2 people are going through the bins in one corner of the room to find that special LEGO piece they’re missing, holding it up against the printout to make sure that axle’s the right size…

You get the picture.

What am I doing all this time? Trying to keep one eye on the Help List on the board, letting kids know they’re next for my help, circulating through the room, fending off questioners who want to skip the HelpList, listening and watching for frustration (not always a bad thing!), nabbing the odd student who isn’t focusing and getting him refocused, checking the clock so I don’t forget to give the 5-minute warning (time to clean up! LEGO sweep at your feet! turn off your robot and put it in the closet! hang up your programming cable and restart your computer!)… every class is a trip.

I wouldn’t have it any other way.

Minecraft and Python — text-based coding!

For my first foray into text-based coding, I recently moved to coding Minecraft with Python. Or “Mython”, as I affectionately call it. I’ve tried other things, like Small Basic and GameMaker (GML, their text language) and, while students can learn from any platform, I felt Minecraft offered more bang for the buck.

The engagement factor is off the charts for Minecraft. I’d be crazy not to try to tap into that. So I launched a year-long exploration of various coding environments for Minecraft(you can see my now somewhat-dated presentation from CSTA 2015 here). My conclusion was that Python offered the best entry-point, and the amount of support available tipped the scales for me. Here’s why:

It’s fairly easy to install and available on Mac, PC, Linux, and Raspberry Pi. For the first three, you’ll need Minecraft, Python, and an implementation of a Bukkit server so that each student can run her own instance of Minecraft. She will also need a Minecraft license (which does cost $27US, but many kids have one already). The beauty of Mython on the Raspberry Pi is twofold — no need to purchase a Minecraft license, since Mojang donated an early version of Minecraft to the Raspberry Pi Foundation. And the Bukkit server is not needed. So there are two big steps you can skip, if you’ve got a set of Raspberry Pi’s (see my chapter on RPi for many reasons why you should consider this).

So why Minecraft?

Engagement level is super high.

Most kids have some familiarity with the game.

The ability to “mod” Minecraft is enticing (though this isn’t modding in the strict sense of the word).

Support is good. I highly recommend getting a copy of the Mython “bible”: Adventures in Minecraft by David Whaley and Martin O’Hanlon. These two gents from Great Britain literally wrote the book on coding Minecraft with Python, and it’s all laid out in an attractive, logical, and clear way, with lots of cool challenges to extend your learning. The authors host an awesome website (www.stuffaboutcode.com) which has a forum for those thorny questions. They are more than willing to help out, and I’ve found these two to be always helpful. In addition, they are on Twitter and have always responded quickly, kindly, and accurately to my questions. And version 2 of Adventures in Minecraft now has support for the Microbit board!

Check out the appendix of the book for more resources.

Here’s how I “teach” Mython. As you might gather from my pedagogy, there’s a reason I put “teaching” in quotes. I stole the idea of the “hackpack” from Chris Penn in Great Britain, as well as some of his excellent code ideas and challenges. I print out “hackpacks” for each student. These include anywhere from 4-7 programs on a particular topic (the first covers basics and building, the second covers triggers, etc.). The code is liberally commented with explanations of what the code does, how it works, analogues to Scratch, gotchas, and whatever I think will help the students understand the code.

And yes, I give them a printed paper copy of the code. That’s by design. I know that copy/paste works great for getting code, and I use it all the time. However, I believe when a student is learning a new language, the muscle memory that she uses by actually hitting the keys and looking at the screen is invaluable in making it stick. It also gives the student a fabulous opportunity to become personally acquainted with error messages! I tell them that error messages are their friends. They don’t believe me, of course, but it’s true, because Python is training them to speak in a way that it understands!

That, of course, is the big difference when we take the training wheels off! It’s now possible to make syntax mistakes! Spelling! Punctuation! Capitalization! Indents! All of it matters. And Python doesn’t know “what you meant”; it only knows “what you said”. Sorry! But welcome to the wonderful world of code.

The good news is that students want to make their code work, and they’re willing to keep at it, fixing errors, until it works. Aha, the magic of Minecraft! Much preferable to doing coding exercises that sort lists or do math or any of the other introductory exercises I’ve seen. I have to confess that my reaction to all of those is a great big “meh”. Who cares? I already know what 8 + 7 equals. Doing it in Python doesn’t make it much more palatable. But if I can figure out how to teleport myself 80 blocks up in the air and 40 blocks to the east, well, that’s cool! And incidentally it’s also teaching a 3-dimensional coordinate system, but shhh…. stealth teaching, remember?

So they get their hackpack, and they type in the code, and it works! Fiero! The dance of joy! But they don’t actually earn any credit for that. I tell them, “Congratulations, that means you can type.” To earn points, they must code what I call a “reverse”. That is, they have to take that code and do something different with it. For instance, one of the hackpacks has code that updates my position every second and displays it in the chat window with the relevant x, y, and z position. The “reverse” is to display it every 4 seconds. Hmm… how to do that? Well, where in the code do you say to display it every second? We look at the loop (while True:) and find the code that says to get my position and post it to the chat. Do you see anything that says to do it every second? Oh… time.sleep(1)! The light goes on, and they swap out the 1 for a 4! Easy peasy! But they’ve learned about a loop, they’ve learned how to get and update my position continually, they’ve learned how to print that to the user (Hello World!), and they’ve learned about delays as well (and that you have to import the time library in Python for it to work).

And I didn’t have to stand at the front of the class and say, “Today, class, we are going to learn about… now follow me as I type on the screen and type that exactly, all together now…” Yawn. Students do it at their own speed and find their own “aha moments”! And they get to see it actually happen in Minecraft, on their screen, caused by the code that they just typed in! Woohoo!

So you can see why I’m excited about using Minecraft for teaching coding!

Another carryover, I’m hoping, is that when they go from my class in 8th grade to our 9th grade CS class, where they will code their own original games using the Pygame library, that at least some of this will be burned into their brains. At the very least, they’ll remember they have to be careful with what they type, since they learned firsthand how picky “the Python” can be!

So if I had a standards-based curriculum, what CS standards and concepts have I “covered”? By the time we’ve finished the unit, we can check off: conditionals, events, triggers, 3D coordinate systems, for loops, variables… in Python, they’ve learned about importing libraries, proper indents, colons and why they’re essential, and how to read Python error messages. But again, shh…. let’s not spoil the fun.

Taking off the training wheels – block and text coding

Most teachers agree that it’s better to start with block-based programming, and I heartily agree. I don’t introduce text-based coding till 8th grade and that’s only after my students have had a thorough exposure to a few different styles of BBP. There are so many possibilities that it’s just a matter of choosing what works for you and your students. Here’s what I’m using currently:

I think Microsoft really hit it out of the park with the MakeCode environment for several reasons:

it’s free.

it’s web-based, so accessible from a variety of devices.

it works on several different hardware and software platforms and more will be rolled out as we go. As of this writing, it supports Microbits, Circuit Playground Express, the Chibi Chip, Wonder Workshop’s Cue robot, and the queen of them all, Minecraft(only Education Edition, however)! That’s important to me because I use the Microbits in 5th grade, the CPX and Minecraft in 6th, so students can become familiar with the environment and make an easier transition from one to another.

also, did I mention that it’s free?

And of course, there is Scratch, just getting ready to release version 3.0 as of this writing. With their web-based environment as well as old-school standalone Scratch, it’s the perfect introduction to block-based coding. I use it for game creation in 7th grade. It’s a wonderful vehicle for learning some advanced CS principles in a relatively painless way: loops, conditionals, events, and variables. I say RELATIVELY painless because students still have to wrap their heads around the concepts. But they don’t also have to deal with syntax errors, and the results of their own misspellings and mispunctuations.

There are lots of other platforms that can work for you and your students. My advice is to pick one or two and stick with them. The important thing is for students to start to understand the CS concepts, so that when you introduce text-based coding, they understand what they’re doing.

A matter of debate is what should the first text-based coding language be, and when should it be introduced? I prefer Python. It’s more accessible, I think, than other languages, because it’s more like natural language than say, Javascript. So it has a pretty easy on-ramp, and lots of ceiling. It’s a language that students can grow with, with its thousands of libraries for everything from Raspberry Pi input/output to gaming to scientific algorithms. There are jobs out there that require Python. And the Computing At School curriculum in Great Britain uses it as the first text-based language. That’s a pretty powerful endorsement.

Downsides of Python? There are a couple. Perhaps the biggest is its sensitivity to incorrect tabbing. If you use IDLE, the built-in editor, it will automatically tab lines correctly in if statements and for loops, but I’ve seen students reach maximum frustration when the code just wouldn’t work, and it turned out to be a misplaced tab. Ouch.

Other languages? I’d suggest 2 other possibilities: Small Basic and Javascript, in that order. Small Basic is Microsoft’s technology for entry into text-based coding. It has auto-complete (usually useful), and introduces dot notation, an important feature that they’ll run into in many languages. It’s also very natural language-like, more so than Python. I’ve found that students find that it just makes sense. Plus it’s got a great built-in turtle graphics system, which is a fabulous way for students to SEE the results of their code.

Problems with it? No jobs out there that use it. And where do you go next? I suppose you could argue for Visual Basic, but that’s not a path that most schools go down in high school. So it’s a bit of a dead end.

Javascript was chosen by Microsoft to be the language that MakeCode translates to. I have to say that I really wish they had chosen Python for this. However, it is used widely everywhere, on the web and elsewhere. And it’s certainly more accessible to most students than C#, C++, or (God help us) Java.

Whatever language you choose, that initial experience of what I call “taking off the training wheels” can be challenging to most students. I try to liberally comment my Python sample code with references to what they know in Scratch. For instance, I will do this

while True: #same as “forever” in Scratch

But there is inevitably going to be that time of discomfort as students try to make that leap to Python syntax. This might be an argument for using Javascript in the MakeCode environment, since you can switch from blocks to text with the click of a button. I haven’t tried this, so I can’t recommend it. Truthfully, I think I’d rather not have those training wheels so convenient, since students might be tempted to not take them off, and thus never truly learn how to ride that bicycle (to strangle the metaphor).

Middle School Computer Science — whaat?

I’d like to say that this post will be the first in a series of posts. But I’m hesitating because I know how my relationship with this blog works. Kinda like a long-term friend that you know you should be contacting but somehow you don’t. And then you feel guilty.

So I’ll just start. I teach middle school computer science. That means grades 5-8 in my school. And I’m lucky that it’s a required course. I have every student in the middle school for a full quarter (about 9-10 weeks). 5th and 6th graders have me 3 times a week, 7th and 8th, 5 times. I’ve been at this for about 15 years and I’m busily building out my curriculum. As you know if you’re in this world, nothing ever remains the same. There’s always a new programming language, a new robot, a new board, a new computing platform… My job is to survey the landscape, see what’s new and cool, and decide what fits in my program.

I have a few guidelines that I use to decide what I incorporate. First and foremost, will kids love it? By that I mean, will they come running into the room, eager to fire up their computer or robot, and get started? If it doesn’t pass that test, it doesn’t make it into the program, sorry. So that means it’s got to have a fairly easy on ramp, and enough ceiling to keep even the advanced kids hopped up and moving ahead.

Secondly, will it work for what I call “stealth learning”? Will the projects and challenges that I use to frame their learning keep them engaged, challenge them, and advance their skills and knowledge in computer science? That’s the stealth part. I very rarely start a class with me talking about a concept (what the rest of the educational world calls “teaching”). I would much rather give them a challenge — as in, “Can you make this robot navigate around the room continually without bumping into anything?” I know this might go against the way that a lot of people frame learning, and I’m OK with that. I’m not saying it’s the only way to do this; it’s just the way that I prefer to do it. And I’m not opposed to “traditional teaching” if it’s obvious that it’s necessary for a student or a class. More on that later.

So for programming concepts, you can probably spot what the challenge up above requires. Events and loops, for starters. If/then… if the robot senses an obstacle, then do something to avoid it. And keep doing that, over and over again….

But how do they figure that out, you ask? You haven’t even introduced them to the programming environment! I’ve found that most middle schoolers only want enough “instruction” to get started and help them achieve their goal. So I give them as little as possible, and only when they’re wanting to learn it. It’s called just-in-time learning. Not a new concept, and I didn’t invent it. But I know it works.

Thirdly, will the tech support a big project? I believe in deep dives into the technology, and big projects that go for several weeks. I break them down into bite-size challenges, some hard and some easy-peasy. Finish all the required ones and you get an A- or 90. If your goal is to “level up” to an A+, you’ll have to complete an extra challenge of what I fondly call “extra awesomeness”. You’ll have to take the basics of what you’ve learned throughout this project and apply them and extend them in a new and creative way. And that’s your choice as a student. If you’re happy with that 90, that’s up to you. I will say that the great majority of my students opt to “level up”. But again, that’s up to them.

And lastly, where does this technology fit in providing an entry point into CS? There are so many avenues in — robotics, programming, game creation, physical computing, art and music… I try to make sure that each grade has a variety of entry points. What jazzes one kid won’t work for another, but I want to provide enough variety that every student will come out and say something was super fun for them!

And while we’re on that subject, let’s talk about the F-word.

Fun.

I know it’s a dirty word in some educational circles. If the kids are having fun, they obviously aren’t learning, because learning is supposed to be hard. My hero, Seymour Papert, coined a term that I live by: “hard fun”. I promise this to every class I have on Day One. I guarantee you that what you do will be fun… and it will be hard. And you may not know what I mean today, but in a few weeks, you will! The fun part is getting stuff to work, whether that’s a game mechanic or a robot challenge. But yes, it can be hard to get there. Fortunately, because it’s fun, you’ll stay engaged, on task, and working hard to get it going the way you want. And nothing is better than that feeling you get when it finally works!