Lab 1 — Physical Computing

Sam Stromberg
3 min readSep 6, 2021

Sam Stromberg, C262 Tangible User Interfaces, Fall 2021

Description

This lab was a straightforward way to build a circuit and practice controlling it with an Arduino. I started by connecting the Arduino to my laptop and uploading/running the Blink sample program to verify the connection and software worked, then I began editing and re-uploading the program to generate some variation in the built-in LED on the PCB.

Next, I built a simple circuit, from pin 13 to my breadboard, where it ran through a resistor and green LED bulb before returning to the Ground pin on the Arduino. Because pin 13 also runs the built-in (amber) LED, I was able to activate the circuit using the same program as before.

Finally, I built two circuits running in parallel, described in the Further Exploration section below.

Components

  • Arduino Uno
  • 2x 220Ω resistors
  • 3x LED bulbs (red, green, blue)
  • Jumper wires

Code

This was my initial code, generating three flashes of different duration on both the built-in amber LED and, once I wired the circuit together, the green LED on the breadboard.

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

void loop() {
digitalWrite(BUILTIN_LED, HIGH);
delay(1000);
digitalWrite(BUILTIN_LED, LOW);
delay(1000);
digitalWrite(BUILTIN_LED, HIGH);
delay(800);
digitalWrite(BUILTIN_LED, LOW);
delay(800);
digitalWrite(BUILTIN_LED, HIGH);
delay(600);
digitalWrite(BUILTIN_LED, LOW);
delay(600)
}

Arduino Uno connected to breadboard with green LED lit

Further Exploration

In reading more about the board, I learned that the ‘high’ and ‘low’ voltage levels for the digital output pins are all the same, so using pin 13 — which can be declared either by number or using the “BUILTIN_LED” alias — differs from other output pins only in that it also lights the amber LED on the board. This seems like it will be useful for debugging later on, but for this week’s activity, the takeaway was that a circuit with a resistor + LED can be wired to any output pin.

To illustrate this, I connected a second circuit off of output pin 8, running through the same 220-ohm resistor and then through two LED bulbs. The ground side of the second bulb is landed on the same row of the breadboard as the pin-13 circuit, so the two share a single jumper wire back to ground.

I then modified the Arduino program to alternate between the two circuits, then both-off, both-on, before repeating. I wanted to see if I could see a difference in the brightness of the LEDS either for the two bulbs in series or when both circuits were on simultaneously, but didn’t discern a difference (in a well-lit room at midday) — a photoelectric sensor may reach a different conclusion.

void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(8, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(8, LOW); // doesn’t do anything first time, used when looping
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on
delay(800); // wait

digitalWrite(LED_BUILTIN, LOW); // turn the LED off
digitalWrite(8, HIGH); // turn the pair of LEDs on
delay(1000); // wait for a second

digitalWrite(8, LOW); // change back to single LED
digitalWrite(LED_BUILTIN, HIGH);
delay(600); // wait

digitalWrite(LED_BUILTIN, LOW); // change back to pair
digitalWrite(8, HIGH);
delay(1000);

digitalWrite(8, LOW); // change back to single
digitalWrite(LED_BUILTIN, HIGH);
delay(400); // wait

digitalWrite(LED_BUILTIN, LOW); // both off
delay(25);

digitalWrite(LED_BUILTIN, HIGH); // both on
digitalWrite(8, HIGH);
delay(1000);
}

A second circuit connects Pin 8 to the red and blue LEDs before landing in row 12 of the breadboard, sharing the jumper wire to ground.

--

--

Sam Stromberg

2nd-year Masters student at the UC Berkeley School of Information. Moving into Product; interested in data and uncertainty, sensor data, behavioral change.