Category Archives: programming

Playing with Programming

I’m teaching AP Computer Science Principles this year following along with the CS50 AP from Harvard. I like it, but this curriculum is way too heavy on the coding end to really match the intent of APCSP.

My plan next year is to mix and match Code.org’s material with ideas from CS50, but instead of C we’ll use JavaScript. With this in mind I’ve been playing with p5.js. I like it a lot for two very important reasons. First it gets students to graphics right away. It’s a lot easier to get student excited about code when they can create cool pictures on the screen than it is when all the do is print text.

The other thing I really like about JavaScript is students can run their code on pretty much any device with a modern web browser. As an example, check out the sketch below. I created after watching a cool video by Dan Shiffman. I made this in Openprocessing, a cloud editor for p5.js. If you’re interested, Wikipedia has a great explanation of the math involved in my program.

Learning with OpenSCAD

I’m currently teaching a class to pilot AP Computer Science Principles (will be AP for the first time in the 2016-17 school year). At the beginning of the second semester I decided to deviate from my planned curriculum and drop in a little 3D printing. I had students play with OpenSCAD. OpenSCAD is used to create 3D models with programming rather than more traditional means.
 OpenSCAD is really cool for a number of reasons. If students have any experience with writing code they can dive right in. They quickly realize there are many different ways to create the same part, just as there are always multiple ways to get any program to do what you want it to. Most of these ways will involve thinking in 3-dimensional coordinates while also thinking about positive and negative space. Depending on the chosen approach students may also need to bring in a variety of mathematical knowledge and skills they’ve developed over the years.

The task I gave my students was to develop a stand/holder for their own cell phones. It took them a bit to settle into this idea. I kept getting questions like, “Do I need to plan for a case?” To which I’d reply, “I don’t know, does you phone have a case?” I really wanted them to plan for a holder for their own phone.

In the future I’ll need to put some limits on their designs. Most designs were much bigger than they needed to be, many would easily hold an iPad. Maybe I’ll put a limit on the mass of plastic they could consume. I also need to make sure their design will fit the printer. I had one that would not.

After printing their stands they all realized there were problems with their designs, things that were not obvious before they tried using the physical objects. This was a great lesson and gave us a chance to talk about rapid prototyping and iteration. Each student shared their first designs with the class so everyone could learn from each other’s mistakes. The designs were then updated to fix the problems. In the redesign I also had students add in variables for phone size. This would then allow the program to be used to make a holder for any phone by simply changing the values of the variables for phone height, width, and thickness.

Overall I really liked this assignment. Students got to use their programming knowledge in a new way with a new language. I personally delivered no instruction in OpenSCAD. Students had to rely on the principles of computer science they’d already learned, tutorials found on the net, and each other, just as they would in the real world. The task was simple enough that I knew this would not be a problem. I will be doing this again as a planned part of the curriculum next year, but I’ll add in design constraints related to size and total cost of materials.

Arduino or PICAXE?

This is a pretty geeky post… You’ve been warned.

Among the courses I teach is electronics. It is a one semester course, where we cover basic theory in the first half of the semester and students breadboard circuits for the second half of the semester. I inherited the course and its general structure from the previous electronics teacher and it seems to work pretty well.

Anyway, I’ve been thinking about changing it. I’ve been wanting to incorporate microprocessors into the course for some time, but I’ve been daunted with either the price tag or for the cheap stuff with the technical know-how that I just don’t have. By bringing in microprocessors I can also get students doing some programming . Additionally, a lot of electronics these days includes embedded microprocessors.

Enter the PICAXE and Arduino micro-controllers. Both can be had relatively cheaply and are fairly easy to program. Unfortunately I discovered these at about the same time. If I only knew about one of them I’d have been content to buy a bunch and get to work redesigning my course. As it stands right now, I have no idea which one to choose. So I’m writing this post to get my ideas down and I’m partly hoping for some insight from potential experts.

PICAXE: The PICAXE micro-controller is a Pic based chip that has a bootloader loaded onto it allowing for a very simply programming cable to be used. It can be programmed using a form of basic or with a flow chart based interface. There are some great guides online for its use, but they’d have to be edited a bit to make them usable for my course. There are multiple versions of this chip with different numbers of inputs/outputs. The programming is slightly different from chip to chip.

Pros: Cost. The chip (8M) itself costs less than $4. Theoretically students could easily make permanent projects with this. Basic programming: I know basic and basic programming is relatively easy.

Cons: The 8M, the chip I’d focus on, is a bit limited. There are other chips we could add in, but their structure is different. Apparently limited availability. I’d really have to plan ahead to ensure I had the supplies I’d need (unless I want to order from the UK). Windows only.

Arduino: This board is really a Basic Stamp replacement. I’d thought it was going to be outside of the price range I’d set for the course, but then I found a supplier who supplies a version that I can get for $11/board in bulk. The programming for this chip is in a C++ like language. There is also a lot online support for this board and at least one project designing a course in basic electronics with the Arduino as the platform.

Pros: Expandability. This chip has some wickedly cool potential. It interfaces circuitry directly with a computer easily, making it possible to create circuits that control or respond to functions on the computer. Support for Mac, WinXP, and Linux.

Cons: I don’t know C++ or any other object oriented programming language. More expensive so it would cost more for students to make permanent projects.

I guess the bottom line is the PICAXE is probably simpler to start using but while the Arduino has a steeper learning curve at the start it allows for more advanced functions more easily. At least I think. Right now I’m leaning towards the Arduino. I’ve already got one independant student working with the PICAXE. I’ll get a couple working with the Arduino this semester as well and see what they all think.