Note: “codebook” entries below are verbatim pasting of all of the code we used in class. It’s possible they may not compile (i.e. may have errors) if we left things unresolved, or were writing pseudocode, etc.

#1 Tuesday 8/28/18: intro

  • Introduction to course content, policy, and housekeeping (with reference to the course website’s home page)
  • Go around sharing names, pronouns, things people have built
  • Quick overview of the Phys Comp Lab space (electronics, tools, resources, storage)
  • Arduino Uno board tour (pins, components, ports, LED indicators)
  • Navigating the Arduino IDE (Integrated Development Environment)
  • Writing our first blinking sketch

Codebook: terrible_example

Note: this is code that’s formatted pretty terribly. But it compiles* without a problem, because with a few exceptions, the Arduino software environment (i.e. C/C++) doesn’t care about spaces or line breaks.

You can write code that looks like this, but it’s going to be very difficult to read or debug!

* “It compiles” means that the Arduino software is able to read and understand every single piece of the instructions. It does not mean the instructions are “correct,” per se, or that the software will do what you intended.

void setup(){
  pinMode(13, OUTPUT);
}

void loop(){
  digitalWrite(13, HIGH)    ;      delay(1000);digitalWrite(13, LOW);
delay(20)   ;   }

Homework 1 assigned, due at start of class 2

#2 Thursday 8/30/18: living the blinking LED dream

  • quickly run through sample projects students submitted for Homework 1
  • quick show-of-hands voting for lab hours
  • hand out some kit contents:
    • Arduino
    • breadboard
    • jumper cables
    • potentiometer
    • bin
  • simple schematic symbols
    • trace/wire
    • node
    • resistor
    • Arduino with pins
    • ground
    • LED
    • incandescent bulb
  • breadboard internal wiring
  • always maintain sufficient resistance between 5V and GND!
  • wire up one blinking LED
void setup() {
  pinMode(13, OUTPUT);
  pinMode(10, OUTPUT);
}

void loop() {
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  delay(20);

  digitalWrite(10, HIGH);
  delay(1000);
  digitalWrite(10, LOW);
  delay(20);
}

#3 Tuesday 9/4/18: reading inputs from the world and V=IR

  • IDeATe Assistant Director Kelly Delaney speaks to the class about different IDeATe facilities and academic courses
    • access to lasers, 3D printers, wood shop, etc.
  • there is an emergency exit door; there is a fire extinguisher; there are receptacles for sharps; there is a first aid station
  • expectations clarification: “you’ll use classtime to focus on the class, and not the fun things happening inside your phone or out on the internet.”
  • office hours clarification: office hours with RZ also available by appointment
  • Sharing is caring!
    • exception: influenza.
    • Please stay home and rest if you’re sick! From the University Health Services: “All people with fever are advised to stay home and out of public areas until they are fever-free for 24 hours without the use of an anti-fever medication.”
    • also please cough/sneeze into the crook of your elbow rather than your hands
    • and wash those hands!
  • go over Homework 2
  • using the IDE’s built-in reference
  • writing comments in your code (so it’s “self-documenting”)
  • voltage is pressure; current is flow; resistance is resistance
  • voltage drop and implications for a potentiometer
  • V=IR: how much resistance is needed, at minimum, between any pin and ground? Between 5V and ground?
    • the maximum rated current for any I/O pin is 40mA, and more-reasonable safe current is 20mA. Therefore minimum resistance between any I/O pin and gnd is:
    • the maximum rated current through all I/O pins is 200mA. Therefore minimum resistance between all I/O pins taken as a group and gnd is:
    • maximum current for 5V pin is ~400mA. Therefore minimum resistance between 5V and gnd is:
  • add a potentiometer as an input (analogRead()) and read values via Serial monitor
  • variables for storing a sensor value and putting it to use
    • change the timing between blink events
  • Project 1 posted; student groups posted by 10 p.m.
  • Homework 3 assigned

Codebook: a partial homework 2 solution, with lots of comments

void setup() {
  pinMode(13, OUTPUT);
  pinMode(10, OUTPUT);

  // turn on both of the lights and wait 1 second
  digitalWrite(13, HIGH);
  digitalWrite(10, HIGH);
  delay(1000);

  // turn the first LED off and wait 500 ms
  digitalWrite(13, LOW);
  delay(500); // makes the arduino wait 1/2 second
  
}

void loop() {
  // turn on LED1 and turn off LED2

  // wait 500 milliseconds

  // switch which LED is on and which is off
  // send Serial line back to computer

}

Codebook: a simple demonstration of printing analogRead() values to the Serial monitor or plotter

void setup() {
  pinMode(A0, INPUT);
  Serial.begin(9600);
}

void loop() {
  int potentiometerValue; // this line makes a variable
  potentiometerValue = analogRead(A0); // pours the value of analogRead(A0) into the variable potentiometerValue
  Serial.println(potentiometerValue); // send the value potentiometerValue currently contains to the serial port
}

#4 Thursday 9/6/18: switches, buttons, and servos

  • go over Homework 3
  • RZ is adding extra lab hours tomorrow Friday 9/7: 1–4 p.m.
  • add a button as another input
    • floating inputs give floating signals!
    • instead, use a pull-down resistor
    • reading resistor color codes
  • driving a servomotor (hand out servomotor)
  • hand out photoresistor
  • a million little pieces of software to learn (or review)
    • using the built-in reference in the IDE
    • variables, variable types, and variable scope
      • global variables are great for pin assignments!
      • variable types that we care about for the time being: int, boolean
    • if()else
  • Homework 4 assigned

Codebook: reading one button and one switch

int BUTTONPIN = 2;
int SWITCHPIN = 4;
int LEDPIN = 10;

void setup() {
  pinMode(BUTTONPIN, INPUT);
  pinMode(SWITCHPIN, INPUT);
  pinMode(LEDPIN, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int buttonState = digitalRead(BUTTONPIN);
  int switchState = digitalRead(SWITCHPIN);
  Serial.print("buttonState = ");
  Serial.print(buttonState);
  Serial.print(", switchState = ");
  Serial.println(switchState);
  
  if (buttonState == HIGH && switchState == LOW){
    digitalWrite(LEDPIN, HIGH);
  }
  else{
    digitalWrite(LEDPIN, LOW);
  }
  
  delay(5);
}

Codebook: a simple servo example

#include<Servo.h>

Servo june;
const int JUNEPIN = 7;

void setup(){
  june.attach(JUNEPIN);
}

void loop(){
  june.write(10);
  delay(500);
  june.write(170);
  delay(1000);
}

#5 Tuesday 9/11/18

  • go over Homework 4
  • analogWrite() and PWM
  • soldering (quick demo)
    • soldering through-hole parts onto a PCB
    • soldering wires together
    • using heatshrink
  • using hand tools (quick hacksaw and pull saw demos)
  • ADXL335 accelerometer (hand out part)
  • ultrasonic ranger and using contributed libraries (hand out ultrasonic ranger)
  • external power (using a battery or power supply)

Codebook: simple analogWrite() example to demonstrate running through the complete range

const int SIGNALPIN = 6;

void setup() {
  pinMode(SIGNALPIN, OUTPUT);
}

void loop() {
  for(int i = 0; i < 256; i++){
    analogWrite(SIGNALPIN, i);
    if (i == 128) {
      delay(500);
    }
    delay(50);
  }
}

Codebook: print ADXL335 accelerometer values to the serial monitor

// set up pin assignments
const int XPIN = A0;
const int YPIN = A1;
const int ZPIN = A2;

void setup() {
  pinMode(XPIN, INPUT);
  pinMode(YPIN, INPUT);
  pinMode(ZPIN, INPUT);
  Serial.begin(9600);
}

void loop() {
  // to save a bit of typing, the Serial.print statements can embed the analogRead in themselves: 
  Serial.print(analogRead(XPIN));
  Serial.print(" ");    // spaces between values to separate them
  Serial.print(analogRead(YPIN));
  Serial.print(" ");
  Serial.println(analogRead(ZPIN));     // line break only needed after the final value
  delay(50);
}

Codebook: modified NewPing example that lights an LED to indicate proximity

// ---------------------------------------------------------------------------
// Example NewPing library sketch that does a ping about 20 times per second.
// ---------------------------------------------------------------------------

#include <NewPing.h>

#define TRIGGER_PIN  12  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     11  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

void setup() {
  pinMode(13, OUTPUT);
  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
}

void loop() {
  delay(50);                     // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
  Serial.print("Ping: ");
  Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance range)
  Serial.println("cm");
  if (sonar.ping_cm() < 20){
    digitalWrite(13, HIGH);
  }
  else{
    digitalWrite(13, LOW);
  }
}

#6 Thursday 9/13/18

  • quick review of schematic goods and bads from Homework 4
  • there are big servos available if you want to move something a bit bigger/heavier
  • quick overview of power supplies (just using the 5V terminals for now)
  • multimeter use
    • measuring voltages
    • measuring resistance
    • continuity mode with speaker
  • review of documentation requirement (really: just take lots of pictures as you go)
  • work day for Project 1, which will be presented on Tuesday

#7 Tuesday 9/18/18

  • Project 1 project presentations and crit
  • Homework 5 assigned (prep for our guest speaker)

#8 Thursday 9/20/18

  • guest speaker Laura Poskin, MPSG
  • DSLR camera tutorial
    • photography basics, including the triad of film speed, aperture, and shutter
    • hands-on camera use in the classroom and in the IDeATe Photo Zone

#9 Tuesday 9/25/18

  • Project 1 crit for group with modified deadline
  • quick debrief of Laura Poskin visit
  • review of data types available on the Arduino
    • bool: 0 or 1 (i.e. false or true, LOW or HIGH)
    • int: whole numbers –32,768 –> 32,767
    • long: whole numbers –2,147,483,648 –> 2,147,483,647
    • unsigned versions of both of those:
      • unsigned int: whole numbers 0 –> 65,535
      • unsigned long: whole numbers 0 –> 4,294,967,295
    • float: any value –3.4028235E+38 –> 3.4028235E+38
    • char: a character like a or %
    • String: a series of characters like hey there or A@8j0)
  • juggling multiple tasks without invoking delay(): or how to blink without blocking
  • Homework 6 assigned, due Thursday, Sept. 27th; grading returned by Tuesday, 10/2
    • I’d prefer to assign this over a weekend but since we can’t, we’ll use class time to get started!

Code book: how to make periodically-recurring routines without delay()

unsigned long halfSecondLastTime = 0;
unsigned long thirdSecondLastTime = 0;
bool halfSecondLightState;
bool thirdSecondLightState;

if (millis() - lastPrint > 1000) {
  Serial.print("data that gets reported once per second");
  lastPrint = millis();
}

// blink this light every half second
if (millis() - halfSecondLastTime >= 500) {
  halfSecondLightState = !halfSecondLightState; // this line flips the state
  digitalWrite(HALFSECONDLED, halfSecondLightState);
  halfSecondLastTime = millis();
}

// blink this light every third of a second
if (millis() - thirdSecondLastTime >= 333) {
  thirdSecondLastState = !thirdSecondLastState;
  digitalWrite(THIRDSECONDLED, thirdSecondLightState);
  thirdSecondLastTime = millis();
}

#10 Thursday 9/27/18

#11 Tuesday 10/2/18

  • first meeting with older friends! agenda

#12 Thursday 10/4/18

  • debrief/discuss Tuesday’s meeting (little slide show for fun, too)
  • code posting finally fixed on WordPress: groups go onto their own documentation pages and post code correctly (in class)
  • demo: motors we haven’t used yet: DC motor
  • demo: sensor we haven’t used yet: IR proximity sensor
  • due: Project 2: brainstorming sketches and notes for discussion with course staff

#13 Tuesday 10/9/18

  • demo: motors we haven’t seen yet: stepper motor
  • demo: how to mount a panel-mount potentiometer and affix knobs to it
  • review of Project 2 prototype requirement for Thursday
  • work day! Take pictures as you go! Take pictures as you go!

#14 Thursday 10/11/18

  • fill this form out to request parts for your project
  • did you fix prior documentation from Project 1? Email me, I will look over it and regrade appropriately!
  • safe use of a power supply: isolate (separate) the power supply positive voltage from the Arduino’s 5V line!
  • powering your project: 7–12V on the Arduino’s VIN pin will do the trick (battery or wall power)
  • Learning Media Design requests you do a quick survey about documentation practices. They also would like to have follow-up discussions with you (mark that on the survey) and will buy you coffee/desserts!
  • due: Project 2 prototype for brief review
    • fours: students in groups of four give each other four minutes of feedback apiece. Take notes on your feedback!
    • instructor review: Runchang and Zach go around to review each student’s progress individually
  • remainder of class: work day! Take pictures as you go! Take pictures as you go!

#15 Tuesday 10/16/18

  • reminder: Learning Media Design requests you do a quick survey about documentation practices. They also would like to have follow-up discussions with you (mark that on the survey) and will buy you coffee/desserts!
  • early presentation/crit by a student who will be out for Thursday’s crit
  • Useful links page added to “reference” on the left side of the page
  • Work day! Take pictures as you go!

#16 Thursday 10/18/18

  • due: Project 2 final crit (in class, with invited guest critics)
    • class divided into two groups
    • each student in each group presents and answers questions for 7 minutes, then there’s written feedback for 4 minutes

#17 Tuesday 10/23/18

  • two catch-up crits from last week (run concurrently at the start of class)
  • midterm grades posted; these comprise ~40% of the course grade, so there’s plenty of room to improve
  • brief review of documentation requirements for Project 2 (due Thursday)
  • Big potpourri of technical notes: things to consider while building projects (all of them based on my observation of student practices as you prepared for Project 2)
    • When you’re facing a deadline, begin by aiming to build a “minimum viable product,” rather than the most-possibly-elaborated version of what you’re trying to make. Start simpler and add on features as time allows.
    • Mechnical fabrication is very difficult. It is often more time consuming to troubleshoot than software or electronics, and you should allocate time accordingly.
    • I advise turning on “all” compiler warnings in the Arduino IDE (File->Preferences). Then, things like the following will give you an orange-lettered warning down in the console area upon compilation:
      • if(x = 10) will compile, but not do what you probably want. It’s not the same as if(x == 10)! Instead of comparing x to 10, it will do the assignment of the value 10 to x, and then proceed to execute whatever is inside of the if().
      • unused variables will also throw a warning message.
      • odd “casting,” where the compiler does its best to interpret one type as another, will also throw a warning. For instance, int y = "howdy" is saving that string howdy into an int (integer) data type…it is almost certainly not what you mean to do. (The correct way to store the data howdy is in the String data type: String y = "howdy", or the char * type: char * y = "howdy".)
    • Unit testing: if when you press a button, the LED doesn’t go on like it should, a great way to begin debugging is by uploading a super simple sketch just to read the button. Once you’re sure that part is working, then move on to checking if the LED is working (with another super short sketch just for that purpose). In simplest terms: the quickest way to solve a problem is to isolate and localize (find) it!
    • Don’t just download or copy/paste software and run it! Read it first so you know what it’s supposed to do. Otherwise, you’re flying blind.
    • It is possible to move Serial data onto an Arduino, not just off of it. You can read about this at the Serial.read() documentation page. You can also have two Arduinos talk with each other by connecting the TX line from one to the RX line of the other, and vice versa.
    • Tie the grounds together!!
    • Use a multimeter to measure resistance, voltage, and continuity.
    • Do not leave very big bare metal tails sticking out of your boards or soldering jobs—these can unintentionally contact each other and create a short. If wires are near each other and can possibly move, they should be insulated.
    • A 5 volt Arduino (such as the Uno) can be powered:
      • by plugging its USB cable into a USB charger, a computer, etc.,
      • by plugging 5V into its 5V pin, or
      • by plugging 7–12V into its VIN pin.
    • There are many different sizes of Arduini available for your different needs. A very incomplete list, ordered from physically smaller to larger:
      • ATTiny85 (5 I/O pins)
      • ATTiny84 (12 I/O pins)
      • Teensy 3.2 (24 I/O pins)
      • Arduino Nano (22 I/O pins (2 of which are only able to do analogRead()))
      • Arduino Uno (20 I/O pins)
      • Ardino Mega (54 digital I/O and 16 analog inputs)
  • review of V=IR problems from last semester’s midterm
  • announcement of student groups and picking older friends’ names at random (particulars are posted on Canvas)

#18 Thursday 10/25/18

  • Guest lecturer Prof. Berntsen from HCII speaks about interviewing methods
  • clarify/fix the group assignments since I mistakenly wrote them down wrong at the end of last class!
  • review the documentation requirement for the interview
  • discuss useful techniques for interviews (with reference to Universal Methods of Design by Bella Martin and Bruce Hannington; PDF of this book is available on the course Canvas site in the “files” section)
  • groups work together to plan out interviews

#19 Tuesday 10/30/18

  • Class does not meet: groups given time to work on interviews.

#20 Thursday 11/1/18

  • interview debriefing
  • defining “behaves-like” prototypes
  • instructor discussion with groups pertaining to their build plans leading up to November 13th’s formative crit
  • documentation for this period will be as in past projects—a few high-quality images of the prototype you make and a slew of process images. Precise assignment to be put online.
  • reminder: any ordering needed should be done soon! Ordering request links are at the top of the “Useful links” page in the reference section.

#21 Tuesday 11/6/18

  • Project 2 documentation grading is under way. Aiming to finish before class Thursday! Apologies for the delay.
  • project grading: unified for all group members unless unusual circumstances arise (this now appears in the project grading rubric)
  • quick project schedule review
  • quick review of prototype process documentation requirements
  • work day for formative crit in seven days!

#22 Thursday 11/8/18

  • Project 2 documentation grades by noon tomorrow if you haven’t already gotten yours!
  • Tuesday crit format information
  • work day for formative crit on Tuesday

#23 Tuesday 11/13/18

#24 Thursday 11/15/18

#25 Tuesday 11/20/18

  • final project group work time

#26 Tuesday 11/27/18

  • final project group work time

#27 Thursday 11/29/18

  • Class observer today: Rachel Bonnette is returning for some follow-up observations. She’s a grad student at Pitt working on an NSF grant with IDeATe faculty members Daragh Byrne and Marti Louw.
  • We’ve invited media to join for our final crit on Tuesday, so there may be a few people taking pictures and doing interviews.
    • If you prefer not to be on camera, please let me know! I don’t want you to feel uncomfortable in the presentations, obviously.
  • brief review of the format for the final crit
  • last work day!

#28 Tuesday 12/4/18

  • Final crit!

#29 Thursday 12/6/18

  • Debrief final crit.
  • Want to raise your documentation grade on a prior project? Make edits prior to Friday 12/14 at 5pm, and be sure to email me (RZ) so I know to take another look at the work.
  • Scanned copies of final project critique forms to be sent to teams some time on Friday 12/7.
  • Please fill out this IDeATe survey. You can get a cookie for your efforts!
  • RZ will be sending out a few personal reflection questions via Canvas. Completing this is an optional exercise, but I’d appreciate it, and as an extra incentive, I’ll release grades earlier for people who complete them.
  • Please clean out your cubby, and take anything you want to keep. The rest will be returned to Phys Comp inventory, given away, or trashed over break!
  • Project handoffs: next week. RZ needs them in-hand by 5pm on Friday, 12/14. Leave in a cubby with a clear label, or hand off directly!
  • Final documentation is due on Friday 12/14 at 5pm.
  • Oops! Forgot to mention in class: I will email out the photos I took at the final crit so you can incorporate them into your documentation if you’d like.