Physical Computing 9/21/22


Faster

This week’s labs went down the smoothest so far. I can feel myself getting more comfortable building circuits and working with the various components.

Programming the microcontroller is another matter. Right now it feels like PComp is racing ahead of ICM a bit, and for what might be the first time in my programming experience, I have to juggle two different (albeit very similar) syntaxes in my head. I’m thinking draw() when I should be thinking loop() and vice versa.

More than the exercises with tone output and servo control–though getting the FSR “instrument” working and servo motor spinning were both rewarding–I found doing the digital input self-quiz to be exactly the kind of refresher and breather I needed to help my programmer brain calm down and start catching up.

Let’s take a look at this simple program I wrote and submitted for the quiz. Write a program that reads a digital input and prints out a message when the input changes from HIGH to LOW:

int buttonStart = LOW;

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

void loop() {
int Button = digitalRead(2);
if (Button == buttonStart) {
 if (Button == LOW) {
  Serial.println("button unpressed or just released");"
  // continually prints this message unless button is pressed
  }
 }
buttonStart = Button;
}

Is it the best or most elegant solution to the prompt? I doubt it, hence the comment I left. Even so, after wrestling with a few things (remembering to declare my button starting state variable at the top, the quote mark syntax for printing a message, and my bland variable names) I have something that, after checking it on the actual circuit, behaves exactly how I expected it to. That’s progress.

A breadboard with a pushbutton wired to an Arduino Nano as a digital input and output to LED.
The LED circuit I made for the digital input/output self-quiz.

Also progress: while working with the potentiometer and speaker, I had Adnan (second year ITP) show me how to use the soldering iron. I know there’s a lot more technique and finesse to be learned with this, but I’m proud of myself for finally learning how to solder. It’s a skill I’ve been wanting to pick up for years but kept putting off because I would get paralyzed at the thought of picking the right project to justify it.

In the end, it took all of a couple minutes to learn the basics, because of course it did. That’s just more motivation to keep pushing.–9/28/22

[Return to ITP blog portal]