︎Back to Interactive & Experience Design

Fall 2023 ︎︎︎ SUNY Purchase ︎︎︎ (DES3090) Interactive & Experience Design

knitting Circle:
intro to programming, python, comments

Internal check-in

So first, check-in with yourself and see how you’re feeling. Are you nervous? Excited? Does doing anything that looks like algebra make you stressed out? Does the word “math” stress you out? Take a moment to see what’s happening and take note of how it changes. Whatever the case, the feeling is valid. Just take a sec to take a breath.

What are we doing here?

All we’re doing is typing words. That’s it.

If you’re getting frustrated, stressed, or see somebody else get something you do not, try to recenter yourself that you’re just typing words. You may just have to retype them (“refactor”), interrogate why they are not working (“debug”), or just make sure you’re updating the correct file.

Most of the words we’ll be typing are a programming language called Python. Specifically it is a version of Python called “CircuitPython” (check here for more about the CircuitPython project and devices that utilize it) which is designed with devices like the CPX in mind. The differences between Python and CircuitPython will probably not come up for us, but if we experience any, we’ll tackle them together.

A note for astute nerds

Note that you can program the CPX in different ways. One is with Circuit Python like we’re doing. Another is something called MakeCode that uses visual blocks and javascript, another is with Arduino which uses C++. You may see examples with these different options; if you want to talk about how to translate them or if they are doing something that you cannot do with CircuitPython happy to do that.

My reasons for selecting Python

(if you care, nbd if you don’t)
If you’ve taken New Directions in Virtual Space or Programming for Visual Artists in New Media you have experienced programming in C# or Javascript (note this is not the same as Java, for reasons that are quite dumb) respectively. Unity is a popular program and Javascript is totally a viable language worth learning but I like Python for several reasons that you may or may not be curious about.
  • Python is good for beginning programmers. It doesn’t use semicolons to indicate the end of lines (which many people forget and then get frustrated about) and it forces you to indent your code in a way that will make it much easier to read. It also doesn’t use something called “datayping” which many people find confusing when they initially learn programming.
  • Python is relevant in design. If you end up doing coding in Glyphs or Robofont, they both use Python. A good next step for making type-based animations is a program called Drawbot, which uses Python. 
  • Even if you don’t end up using Python, you’ll be set up for learning another language effectively. If you learn something more hardcore like C or C++, Javascript, expressions in AfterEffects (this  or PHP, all of those are basically “kinda like Python but with a couple of different rules” so you’ll be in a good place to learn those.

Comments (and why they are important)

Code (Python, assembly, C, whatever) is for machines. A programming language may be made to be easier to read or contain elements that sound like human speech, but they are not in fact human speech. In order to facilitate this process for human beings, there are something called comments. You can use them to describe what your entire code is doing, what a given group of lines is doing or to visually separate elements. Below is the basic red blinky LED example you uploaded to your CPX last week to make sure it works with comments added.︎︎︎

Where to look things up

Some of the things we’ll be coding are specific to the CPX. For example the code the parts that read “cp.button_a” as you can imagine, were made to specifically work with the CPX. If you’re looking for how to do things in Python, look on websites like w3schools. 

This is the documentation for the “API” (Application Programming Interface) or code specific to the Circuit Python Express. 

While that reference is exhaustive, I would recommend looking through examples I linked in the intial part and then looking for the relevant example (the files should be carefully labelled for playing back soundfiles, playing tones, using the IR sensors, accelerometer, etc.)

Be sure to also look at examples and tutorials on the learning side of adafruit’s website. There are also fun guides for projects people have made. Please be mindful that there are other types of Circuit Playgrounds with slightly different specs, as well as other ways to program the Circuit Playground (arduino, makeCode, etc.) keep that in mind when viewing the examples of other folks. That is not any indication you shouldn’t try these methods out and feel free to ask about anything else you’d like to know more about.