Fall 2022 ︎︎︎ SUNY Purchase ︎︎︎ (DES3090) Interactive & Experience Design
intro to programming, python, comments
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
My reasons for selecting Python(if you care, nbd if you don’t)
- 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.
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 upSome 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.