As computing becomes more ubiquitous in our objects, designers need to be more aware of how to design meaningful interactions into electronically enhanced objects. At the University of Washington, a class of junior Interaction Design majors is exploring this question. These pages chronicle their efforts.

Friday, June 12, 2020

Simple Circuit Experimentation: Voltage Divider

Annabel Lee
DES 325 A
Voltage Divider


Getting the Photoresistor to work was one of the most challenging tasks. Guided by the referred instructions, I made sure to followed the tutorial step-by-step. I struggled getting the light to fade out as I hovered my finger over the photoresistor, but it seemed unaffected by the light. However, it turned out that it was my code that was the problem. 

 
Above is the code that fixed the problem! What I mistakenly realized was that previously I did not set ledPin=9; but to 8. A simple human error that caused the entire circuit to malfunction was a learning experience to make sure and double check every component and detail. 

Simple Circuit Experiment: Basic Switch Project

Basic Switch Experimentation


Button Blink
I followed the Arduino tutorial and set up my circuit like this, with the button resistor and LED connected to the ground rail and the button connected so that it can allow power flow between the 5V pin and digital pin 2.


I did not run into any big challenges during this experiment, though I did make a small mistake. I accidentally switched the positions of the 100 ohm and 10k ohm resistors. As a result, the Arduino viewed the switch as always closed / LOW and the LED did not light up. After double checking the band colors with online resources, I was able to identify which resistor was which. The set-up worked after switching them back around.



Original SPA Idea Documentation

Situation: Cat is on the counter.
Decision: If the cat is on the counter, play an alarm to scare him with a blinking LED.
Action: Execute script that plays the alarm and blinks the LED.

I started my experiment by finding a YouTube video that utilized Arduino to create an alarm that would sound in the event that light came into contact with the LDR.

However, this was the opposite of what I was hoping my project would do, as I imagined my cat would be covering up the LDR when he climbed onto the kitchen counter. I ended up making a very small change to the code by switching the variables so that the alarm would sound in the absence of light. I also added some text to the serial monitor as further indication that my cat was being bad.







//set pin numbers

const int ledPin = 13;
const int buzzerPin = 12;
const int ldrPin = A0;

void setup(){
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(ldrPin, INPUT);
}

void loop() {
  int ldrStatus = analogRead(ldrPin); //read the state of LDR value
  if (ldrStatus <= 400) {
    tone(buzzerPin, 300);
    digitalWrite(ledPin, HIGH);
    delay(100);

    noTone(buzzerPin);
    digitalWrite(ledPin, LOW);
    delay(100);

    Serial.println("CAT IS ON THE COUNTER DANGER DANGER");
  }
  else {
    noTone(buzzerPin);
    digitalWrite(ledPin, LOW);

    Serial.println("No cat detected");
  }
}

Nintendo Switch Teardown + Knolling

My reference: https://www.ifixit.com/Teardown/Nintendo+Switch+Teardown/78263



This teardown was actually really fascinating for me to get to learn more about the underlying components behind the Nintendo Switch, a console I use so regularly. I think the most fascinating aspect for me was finally getting to understand the HD Rumble Motor behind the vibration that happens during certain points in games. I always wondered if vibration was something that was damaging to a controller, but it was really interesting to find out that the actuator was designed to be resilient.

Another thing I learned from this teardown that surprised me was the presence of the IR hardware that Nintendo said is able to detect different hand shapes, distance, and in the future will be able to record video. This was really surprising to me and when I read more about the IR camera I learned that certain video games will be taking advantage of this function by having the user do mimic real life functions of the game using the Joycon (e.g. LA Noire requires you to reload by mimic putting a new clip in). It was really surprising for me to learn that a camera that complex could fit into a Nintendo Switch Joycon.

There are still lots of things that I am still learning about the Nintendo Switch but overall I was pleasantly surprised by how simplified the internal hardware was and I think I would feel more comfortable messing around with it in the event my Nintendo Switch ever fails on me.

Original SPA Project Idea - Opening Fridge Detection


Opening Refrigerator Detection

Situation: The refrigerator door is closed.
Decision: If the refrigerator opens and it's been opened several times within a short amount of time and there is nothing inside or nothing has been taken out, then blink the red LED and play an ominous tune.
Action: Execute script that blinks LED and plays ominous tune.

I began my experiment with a simplified version of the decision: just detecting whether or not the refrigerator door has been opened. I would figure out how to determine if nothing has been taken out later.

Initially, I had a couple of ideas for how to detect whether or not the refrigerator has been opened: sense changes in temperature, changes in light intensity levels, or motion of the door swinging.
I eventually decided to use the photoresistor to detect changes in light intensity from the outside of the refrigerator and a paper towel roll to point the sensor at the refrigerator door and block out ambient light.


Circuit



Code

const int ledPin=9;
const int sensorPin = A0;

#include "pitches.h"

// notes in the melody:
int melody[] = {
  NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  4, 8, 8, 4, 4, 4, 4, 4
};

void setup() {
// initialize serial communications (for debugging only):
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(sensorPin,INPUT);
}

void loop() {
// read the sensor:
int sensorReading = analogRead(A0);
// print the sensor reading so you know its range
Serial.println(sensorReading);
// map the analog input range (in this case, 70 - 400 from the photoresistor)
// to the output LED range (0-255)

if (sensorReading <= 950) {
digitalWrite(ledPin, HIGH);
    for (int thisNote = 0; thisNote < 8; thisNote++) {

    // to calculate the note duration, take one second divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = 1000 / noteDurations[thisNote];
    tone(8, melody[thisNote], noteDuration);

    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    // stop the tone playing:
    noTone(8);
  }
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}

Processing Experimentation - Dynamic Bouncing Ball + Fail

Dynamic Bouncing Ball
I added new variables xSize and ySize to manipulate the ball width/height. The ball changes into a random warm color when it hits the height boundaries of the window and into a cool color when it hits the width boundaries. Also, when the ball hits the height boundaries, it increases in size. When it hits the width boundaries, it decreases in size.
float x = 400;
float y = 300;
float xSpeed = 5;
float ySpeed = 5;
float xSize = 50;
float ySize = 50;
void setup() {
size(800, 600);
}
void draw() {
background(0);
noStroke();
ellipse(x, y, xSize, ySize);
x += xSpeed;
if(x > width || x < 0) {
xSpeed *=-1;
fill(random(255), 255, 255);
xSize -= 50;
ySize -= 50;
}
y += ySpeed;
if(y > height || y < 0) {
ySpeed *= -1;
fill(255, 255, random(255));
xSize += 50;
ySize += 50;
}

}

Hot and Cold
This first experimentation was rather simple, so I tried (and struggled, as I have very little coding experience) to create something more complex. My second experiment was to simulate a Hot and Cold game, where the user hovers their mouse over the word "cold" to move it in random increments around the window. As the word approaches a specific point, the word changes color and becomes "warmer". When the word finally reaches the point, it congratulates the user.
The following is failed code. I made changes to it but then regretted those changes and couldn't restore the original. I'll continue to work on it.

String cold = "cold";
String warm = "warm";
String congrats = "congrats";

float x, y; // X and Y coordinates of text
float hr, vr;  // horizontal and vertical radius of the text
float goalX;
float goalY;

void setup() {
  size(400, 400);
  goalX = random(width);
  goalY = random(height);

  // Create the font
  // textFont(createFont("SourceCodePro-Regular.ttf", 36));
  // textAlign(CENTER, CENTER);

  hr = textWidth(cold) / 2;
  vr = (textAscent() + textDescent()) / 2;
  noStroke();
  x = width / 2;
  y = height / 2;
}

void draw() {
  // Instead of clearing the background, fade it by drawing
  // a semi-transparent rectangle on top
  fill(204, 120);
  rect(0, 0, width, height); 
  fill(255);
  ellipse(goalX, goalY, 10, 10);

  // If the cursor is over the text, change the position
  if (abs(mouseX - x) < hr && abs(mouseY - y) < vr) {
    x += random(-50, 50);
    y += random(-50, 50);
  }

  if (abs(y - goalY) > 50 && abs(x - goalX) > 50) {
    fill(0, 0, 255);
    text("cold", x, y);
  }

  if (abs(y - goalY) < 50 && abs(x - goalX) < 50) {
    fill(255, 0, 0);
    text("warm", x, y);
  }

  if (y == goalY && x == goalX) {
    fill(255);
    text("congrats", goalX, goalY);
  }
  
}