App Development with Swift Playgrounds at Vietnam Tech Conference

I presented an hour long workshop on my work using Swift Playgrounds with my high school app development class as part of the Vietnam Tech Conference in February.

In previous years, I used Xcode for the course. This year to see how far I could go using only Playgrounds. I was impressed with how well it worked for giving my students feedback on their programming and letting them prototype apps using the SwiftUI framework from Apple. They have made some really great stuff this year just within Playgrounds.

You can access resources from the presentation here:

Glowing for Halloween with CircuitPython State Machines

This year’s Halloween preparations were a coping mechanism. There is so much going on in the world that I cannot control, objectively more so than ever. Taking on good projects that involve making and coding is a good way to take back a sense of that control.

Halloween has always been an effective deadline for making things happen. I also have a history of making things that involve blinking LEDs for what I wear going out. My first such attempt was an NYC Crosswalk sign thirteen years ago. With my Advanced Automation learning to use state machines, I also wanted to give examples of how these work.

Each of the projects below has links to the code. I teach my students to think about state machines in three steps:

  • what are the different states that the system should be in?
  • what changes to sensors, timers, or other system variables should trigger changes between states?
  • what system variables do you need to read, update, or keep track of during each loop for the system to function?

I’ve found that teaching state machines this way is getting students to write more organized code that is easier to debug because it is more modular than it would otherwise be. I might talk more about this approach in a later post. Right now, let’s talk about getting some circuit boards to light up for Halloween!

Heart of Te Fiti from Moana

My daughter wanted to dress like Moana this year. I knew the best way I could contribute to the costume was to build her a glowing version of the Heart of Te Fiti, the green stone that pushes forward the plot of the movie. I traced the image from this Instagram post to make an SVG that I could use in a 3D model:

I used Onshape to build several versions of a 3D model of the heart that could hold an Adafruit Trinket Express to handle the glowing part. I also added a hole so that this could be used as a necklace after trick-or-treating. Here’s the final version:

I learned a lot about building a model to be 3D printed that press fits together. The back of the necklace presses in to the front with just enough friction that it stays together well enough for at least one night of a nearly five year old to run around with it. There is enough space for a 50 mAh LiPo battery to sit inside and power the necklace for a couple of hours.

The heart in the movie glows a beautiful green. I wanted to add two variations on this steady glow. One is a slowly pulsating green light that is timed to pulse with relaxed breaths in and out. This uses the analog out pin of the Trinket. The other is a pulse resembling a heart beat, handled by the Dotstar pixel in the middle of the Trinket. In the final version, I added a random pause between heartbeats that makes this act like it is actually alive. I really like the effect of the final product:

You can access the code and STL files at this Github Link.

Tony Stark Arc Reactor

Finishing the heart necklace got me thinking about doing something similar for my own costume, but I was running out of time. I decided to go for an Infinity War version and 3D printed this model.

Since I had a Circuit Playground Bluefruit, the ring of Neopixels was perfect to use for powering the glowing effect. The Cyan color of red: 0, green: 255, blue: 255 was about right for the blue glow shown in the movie.

In the version I wore during the day on Friday, the pulsating was really subtle and slow. I changed the code before heading out for the evening because I realized I wasn’t taking full advantage of the Bluetooth capabilities of the Circuit Playground Bluefruit. I added the ability to change the base color of the flash using the Bluefruit LE connect app. I also added some math to make the flashing move between the minimum brightness and the color values, but this led to some weird behavior that I didn’t get to smooth out. Speeding up the flash rate made it hard to see this happen, but this still bugs me. Here’s the final version:

You can access the code for both versions of the Arc Reactor here at Github.

These were really fun projects, and got me to dig into some details of using CircuitPython in more creative ways than in the past. I’m excited to share more as I learn more.

App Development / Distance Learning: SpriteKit

It has been far too long, my friends. In challenging times like these, it’s all the more important to help each other out.

We have been running classes for students at home for the past six weeks here in Vietnam. I want to offer the activities I’ve been doing and resources to you as you look for ideas to use with your own classes.

The first is App Development. This course is meant to be an open workshop class where students learn to code using Swift and build projects in Xcode and Swift Playgrounds. Needless to say, doing this when we are not in the same room has been difficult. I am used to running around the classroom and helping students resolve issues. This is much more difficult when we are not in the same room.

The most frequent mode of operation for class is the try-tweak-reflect cycle. I give students some code that does something, ask them to change something in the code, predict what will happen, and then reflect on the result. They do this a few times until they end up with something that is uniquely their own.

SpriteKit Activities

SpriteKit is a library in iOS that lets you create games. The best way to do this right now is the Swift Playgrounds app which is available for iPad and macOS. There are lots of things you can have students do. Here are some of the ones I’ve done with students. Feel free to use any of it. The app itself has some phenomenal activities that are ready to hand to students and get them learning from the start. If you want a bit more directed learning related to SpriteKit, read on.

I created a video that walks my students from start to finish in creating a simple SpriteKit app that moves a block around the screen with a tap. This was recorded all in the iPad Swift Playgrounds app using the screen recording feature.

SpriteKitStartToFinish (YouTube)

This next video led to something a bit more sophisticated with numbered circles falling and bouncing around.

AppDevelopment – Playing with Classes (YouTube)

You will want to start with this playground downloaded to your computer to use in Swift Playgrounds or Xcode.

After taking students through a few activities like this, I gave them a design challenge. Before we closed school, my plan was to have students build a game to spread awareness of an issue related to the UN sustainable development goals, or SDGs. Here is the description of the project I gave them. (Link here)

Students created some really neat stuff. It took a lot of remote debugging and use of Chrome remote desktop in some cases to make this work, but it was worth it in the end. Here are some highlights of student work:

Write me if you have any questions on how you might use this yourself or with students. We are in this together.

Color Following Robot – RVR, Adafruit Metro, Pixy2

One of the fundamental challenges in maker education right now is the reality that there are many different interesting tools available, but not all of them talk to each other. A notable change, however, is that many of them use open source software that makes it possible to understand how each one works. All that remains is connecting the dots.

About a year ago, I learned about the Pixy2 camera platform. This is an impressive device that can easily learn colors and deliver coordinates of those colors in a camera image through a number of different protocols. The example code is primarily provided through a series of Arduino projects. After working through some Arduino projects with my robotics class a year ago, I decided that barebones Arduino isn’t the way to get students excited about programming microcontrollers. There are way too many semicolons, error-prone libraries, and finicky elements of the C++ language that get in the way of students being able to make things on their own. That said, the Pixy2 is incredibly versatile. It tracks colored blobs quickly and accurately.

Over the past year, I’ve also spent time in the CircuitPython ecosystem. The Adafruit team has done an amazing job of documenting their extensive line of boards (such as the Metro and Feather Express lines) and providing resources through CircuitPython to use these out of the box.

The other release last October was the Sphero RVR line. The first project I gave students a year ago was to build a motorized car using VEX motor controllers, a motorized platform, and an Arduino board. That was a lot more trouble than I expected, especially given that I wanted students to then use the cars they built with a Pixy2. That was a flimsy platform and I should have seen that from miles away. The Sphero RVR is packed with strong motors, a robust sensor assembly, and a solid hackable frame upon which other things can be mounted. This thing drives quickly and reliably, and that’s after only a few months of being available. Commands can be sent to it through a serial port to get it to drive. As of now, the API is limited to driving at a given heading and speed, raw motor power control, and flashing LEDs.

I wanted to be able to demonstrate some concepts of control systems to my high school students. I also had a number of Pixy2 cameras available from my experiment last year. I also had decided that CircuitPython was the way to go for teaching students embedded microcontroller program using the Adafruit boards. It was time to combine these three resources to be able to build a colored object following robot.

After a lot of experimentation, I eventually ended up with the code linked below. The Pixy2 code is a modification of Robert Lucian’s Python port of the API for use with a Raspberry Pi (I think). I did some work to adapt it to use the CircuitPython I2C functions, though it is not the complete feature set. The Sphero Python API is made for use with a micro:bit and MicroPython, but I switched out the code for the MicroPython serial port with that of the CircuitPython serial port on a Metro board. I had to comment out parts of both the Pixy2 code and the Sphero code that I wasn’t using in order to get the code to fit on the Metro. I’m still not convinced that this was the problem as there appeared to be plenty of free memory available when I checked, but I had a number of MemoryErrors pop up without the code commented out.

Here is a GitHub repository with the code.

I’m sure this isn’t as efficient as it could be, but I wanted to demonstrate the simplicity of using information from a camera as a way to build a control system for steering a robot. This is to help students understand a simple proportional algorithm as a control system. My hope is that students will apply this to autonomously steering a robot as part of this year’s FIRST Robotics Competition game: Infinite Recharge.

Google Calendar and Appointments

Like some of my favorite people, I’ve been playing around with Google Scripts in earnest this year to make my teaching work easier. I did this most recently with Google Calendar.

You may or may not know that you can set up appointment slots on a calendar. This is really nice to for others to sign up for appointment times. Google provides a appointment sign up page, lets others book the slots out of those available, and moves booked slots onto your calendar. The only problem is that it requires that those booking appointments have a Google account and sign in. You can’t have a public appointments page that lets any non-Google user view and book a slot. For the purpose of setting up parent conferences, this is a no-go.

You can, however, have a public calendar page that does not require sign-in. The closest way to implement the appointment function would be to show a bunch of appointment slots on that public calendar and have parents ask for the slot that works best through email.

I wrote a script to make these slots. You enter the calendar ID, the start time for the window for appointment slots, the meeting length in minutes, and how many slots to make. The script does the rest.

function addAppointmentSlotsToCalendar(){
  
 var parentCalendarID = "enterCalendarIDHere"
 var parentCalendar = CalendarApp.getCalendarById(parentCalendarID);
 var currentDate = "October 21 2019" 
  var eventTitle = "Appointment Available"
  var startTime = "8:30"
  var duration = 15 //minutes
  var numberOfSlots = 8
  
  
  var startDateTime = new Date(currentDate + " " + startTime)
  var endDateTime = new Date(startDateTime.getTime() + duration*60000)
  
  var currApptTimeDate = startDateTime
  
  for(var i = 0;i<numberOfSlots;i++){
    parentCalendar.createEvent(eventTitle, currApptTimeDate, endDateTime, {description: 'This appointment time is available for meeting with Mr. Weinberg.'})
    currApptTimeDate = endDateTime
    endDateTime = new Date(currApptTimeDate.getTime() + duration*60000)
    
  }

}

I learned some important things that didn’t occur to me until parents started emailing me about the times.

The calendar needs to not only be public, but the event details need to be visible. Otherwise, the public calendar shows all of the slots, but they appear as ‘busy’. This is in the calendar settings here:

The really nice feature that I didn’t realize would work until I started receiving requests for times is filling appointments. All I need to do is change the calendar for the event from the public version to my personal one. This removes the slot from the public calendar and adds it to my own schedule.

I’ve had some fun figuring out how to use automation like this to manage my work this year. There is a lot built into Google Scripts that makes repetitive processes much easier, particularly for the sorts of things that teachers do all the time. I encourage you to find something that you do that might be improved by a script like this and make it a personal challenge to figure out how to do it.

The Two Clocks

The biggest change to my educational philosophy in the past fifteen years can be summarized by two images.

Image one:

Image two:

One instructional model insists on starting at the beginning and working right through to the end. You never have the complete picture until you’ve seen the process from start to finish. Even if you think you know what you’re looking at when you’re halfway done, you aren’t really finished until you actually finish.

The other starts with a wide, blurry view. Structures are clearly there, but are not easy to describe. Over time, that structure reveals smaller structures, which then yields more structure, and so on. You can stop when there is sufficient detail to answer your question, but more time leads to even greater clarity and understanding.

One is part of our tradition. One is closer to how we learn outside of the walls of formal education.

One has worked for a long time; but who has it actually worked for?

On inefficiency

In the robotics and engineering class and app development courses I teach, there are a lot of group projects. I design the projects to be big enough that a single student cannot do everything.

That said, there are tasks though that a single person can do on his or her own. I always bring up the constraints of time and ask students to frequently reflect on whether the group’s time is being used effectively. Three people all building a cardboard prototype for a rectangular box screams inefficiency to me. So does writing a project app from scratch when I have provided starter code to make things easier. 

From an assessment perspective, I want every student to take on every aspect of a project at some point during the semester. All of them should have a chance to write code, wire sensors together, do some fabrication, and test and develop the entire system. For a single project, things don’t always work that way. We need opportunities to specialize too. 

I often need to step back within a single project and remind myself: knowing when to focus on one element, when to shift to a new one, and when to zoom out and look at the big picture – this is a skill. This skill develops over time and comes only from experience. Even adults need to be reminded (or forced) to change their perspective to effectively reflect on a process. We also need to be given opportunities to focus on a single task, leaving all others aside.

 Designing, learning, and making are inherently inefficient because the path to the endpoint is uncertain. Building something new and learning something new, are not about efficiency though. Even when we are following someone else’s instructions to build a project, we might not have completed that project before. Thinking about efficiency is a useful reminder to make deliberate choices about our time. 

I asked a student about one of the classes this week. He wisely said “Mr. Weinberg, you should take the amount of time you think the project should take, multiply it by two, and then just relax. Give us time.”

I often limit the time for projects because I want short design cycles. So far, the only thing that has accelerated progress is being up against a deadline. The learning that happens within that shortened time though is limited.  The rapid progress there is often because students have learned to use their materials.

Learning those materials requires inefficiency to come before it. I need to let that happen. I need to relax there.

Structures and Habits

My courses this year are AP Calculus AB, Robotics and Engineering Technology, and App Development. Given a lot of the work I knew in advance I would be doing this year, I made the explicit decision not to change the Calculus course much from what I did last year.

That leaves Robotics and Engineering Technology and App Development. I wanted both of these courses to be:

  • individualized – students would not all necessarily be working on exactly the same task as others, nor at the same level as others.
  • paced by task and student learning goals, not a unit calendar
  • centered on the process of making and creating 
  • limited in the amount of direct instruction required
  • assessed through documentation and communication of process, not skill level

There is one other critical design requirement that I want to mention.

Almost every course I have taught over my fifteen years has typically followed a gradual release of control model. Students typically start the year by following my directions closely under a lot of structure in the beginning. Then as they understand my expectations and follow my rules, I give a bit more independence to students over time. By the end of the year, we would be a close knit community that knew how to learn together.

I wanted this to be the reverse.

On the first day of each class, I gave students some ideas for what I hoped each of us could celebrate by the end of the semester. I was honest in saying that I didn’t know exactly how we were going to get there.

I did say that each project would be an opportunity for students to set some goals, figure out what was interesting to them in the course of completing the project, and make course corrections as they made progress. Short design cycles would be important to doing this. There was never going to be enough time or enough resources to do everything. Playing and brainstorming, research, testing, and evaluation would all lead to some difficult decisions to be made along the way. That, after all, is the engineering process.

I decided that it was important to put this structure in place at the start, or I might just slip back into old habits. I admit after a few months of doing this that I’ve wavered at times, wondering if I’ve done the right thing. I’ve always come back to the fact that this feels like it is just what students need.

A New Chapter

I’m excited to share the redesign of my blog. The new site and name is to reflect my hope to focus on some different things moving forward in a shift in my role at school.

Previously, you’ve known me as a teacher of mathematics, physics, web programming, robotics…in short, a teacher of lots of things. I’ve principally been a mathematics teacher through the first fifteen years of my career, and continue to do so by working again this year with students in AP Calculus AB.

The big change is that I am coordinating the STEM program for the high school at SSIS. Thus far, I’ve designed a fabrication space for the high school and have reworked two classes to be based on the engineering design cycle. I’ll go more into detail on both of these courses in upcoming posts. I also spend my time attempting to model the making, design, and documentation process for students and colleagues.

The guiding principle for the engineering classes is that making things is the best way to learn – probably no big surprise for those of you that know me. I’m an engineer by training and a tinkerer at heart. I’ve learned a lot through my own projects and want to help students experience this for themselves. So far, it is going very well.

Stick around and I’ll tell you all about it.

The Computational Thinker’s Classroom – Workshop Video

I ran a workshop on computational thinking at the Vietnam Tech Conference this past March. My goal was to give teachers some new ways to think about classroom tasks and the deliberate use of computers to do what they are good at doing.

The general vibe of my talk was consistent with what I’ve said here in the past. Some highlights:

  • We should be using computers to do the tasks that computers do well. This frees us up to do those tasks for which we are well suited.
  • Insisting on basic skills as the entry point for learning is an easy way to put students on the sidelines. Computers are often how we as professionals answer questions that are important or interesting to us. We should help students understand how to use them in the same way.
  • Spreadsheets, databases, and visual models like Desmos and Geogebra are great entry points for computational thinking. You don’t have to be a coder, a mathematics or science teacher, or a technology expert to build these activities for your students.

The video is here:

If you want to do the first three activities yourself and see other resources from my workshop, visit goo.gl/vsT2G6. There is a fourth activity on the page that is mentioned at around 24 minutes in the video that is linked there too.

As always, I’d love to hear what you have to say.

1 2 3 32