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.

Thursday, December 15, 2022

Bud

 

Ian Teodoro, Evelynn Li, Anne Fernandez

 

After a bit of a rocky start during the ideating phase, we finished this quarter off with a playful project that allows users to see the emotions of their plant – Bud.

Video: https://drive.google.com/file/d/1b1eK4uO0vhyuOCsTPBKznY8S0KF_D0U-/view?usp=sharing

Resources:

https://create.arduino.cc/projecthub/electropeak/complete-guide-to-use-soil-moisture-sensor-w-examples-756b1f

https://www.instructables.com/Plant-Moisture-Sensor-W-Arduino/

https://create.arduino.cc/projecthub/projects/tags/plants

Code:

#include "Adafruit_GFX.h" // Core graphics library
#include "MCUFRIEND_kbv.h" // Hardware-specific library
MCUFRIEND_kbv tft;

#include "face.h"

#define BLACK 0x0000
#define WHITE 0xFFFF


int sensorPin = A5;
float sensorValue = 0;
int readVal;
int faceState;

void setup() {
Serial.begin(9600);
uint16_t ID = tft.readID();
tft.begin(ID);
tft.setRotation(1);
tft.fillScreen(WHITE);
pinMode (sensorPin, INPUT);
pinMode (happy, OUTPUT);
pinMode (neutral, OUTPUT);
pinMode (sad, OUTPUT);
pinMode (mad, OUTPUT);
pinMode (dead, OUTPUT);

//moisture
for (int i = 0; i <= 100; i++)
{
sensorValue = sensorValue + analogRead(sensorPin);
delay(1);
}
sensorValue = sensorValue/100.0;
Serial.println(sensorValue);
delay(1000);

}


void happy () {
tft.fillScreen(WHITE);
tft.drawBitmap(119, 200, myBitmapface_happy, 248, 73, BLACK);
}

void neutral () {
tft.fillScreen(WHITE);
tft.drawBitmap(119, 211,myBitmapface_neutral, 248, 42, BLACK);
}

void sad () {
tft.fillScreen(WHITE);
tft.drawBitmap(119, 211,myBitmapface_sad, 250, 69, BLACK);
}

void mad () {
tft.fillScreen(WHITE);
tft.drawBitmap(119, 211,myBitmapface_mad, 248, 89, BLACK);
}

void dead () {
tft.fillScreen(WHITE);
tft.drawBitmap(119, 211,myBitmapface_dead, 242, 69, BLACK);
}




void loop() {
readVal=analogRead(sensorPin);
if ((readVal<=1)&&(faceState!=0)) {
dead();
faceState = 0;
}

else if ((readVal>1 && readVal <=80)&&(faceState!=1)) {
mad();
faceState = 1;
}

else if ((readVal>80 && readVal <=120)&&(faceState!=2)) {
sad();
faceState = 2;
}

else if ((readVal>120 && readVal <=160)&&(faceState!=3)) {
neutral();
faceState = 3;
}


else if ((readVal>200 && readVal <=250)&&(faceState!=4)) {
happy();
faceState = 4;
}


}

Wednesday, December 14, 2022

Heartbeat Lamp

The Heartbeat Lamp allows users to easily visualize and monitor irregularities in their heart rate. With the input received by the Pulse Sensor, the color of LEDs will change according to the heart rate of the user. A low heart rate (below 60 BPM) will result in blue blinking LEDs, a normal heart rate (60 to 100 BPM) will blink green, and a high heart rate (above 100 BPM) will blink red. When the Pulse Sensor is not in use/is disconnected from the user, the LEDs will default to a rainbow.

Libraries used:

1. PulseSensor Playground > Getting_BPM_to_Monitor

2. Adafruit Neopixel > Strandtest

These libraries were combined to access the BPM values and have the lights blink in different colors, speeds, and ranges of individual LED lights accordingly. 


Sample of code for the brighten/darken functions which let us achieve the "blinking" effect.

Code which addresses LEDs according to input received by PulseSensor.


https://www.youtube.com/watch?v=BWRv4IfOzfE&feature=youtu.be




Saturday, June 13, 2020

Capsense Exploration

Using this Youtube Tutorial (https://www.youtube.com/watch?v=stejKa03tdw), I was able to play with the capsense library and which showed the pressure on the wire itself. The capsense library is pretty cool, and I would look for more examples in the future.

Processing Experimentation

For this processing experimentation, I played with the Star code and changed the size and increased the frequency of rotations.

Code for Star:
void setup() {
size(640, 360);
}
void draw() {
background(200,0,0); // background color

pushMatrix(); // left star
fill(204, 102, 0); // not sure how to change individual colors?
translate(width*0.2, height*0.5);
rotate(frameCount / 50.0); // increased rotation
star(0, 0, 20, 70, 6); //increased number of corners
popMatrix();

pushMatrix(); // center star
translate(width*0.5, height*0.5);
rotate(frameCount / 400.0);
star(0, 0, 80, 100, 40);
popMatrix();

pushMatrix(); // right star
translate(width*0.8, height*0.5);
rotate(frameCount / -100.0);
star(0, 0, 50, 70, 8);
popMatrix();
}
void star(float x, float y, float radius1, float radius2, int npoints) {
float angle = TWO_PI / npoints;
float halfAngle = angle/2.0;
beginShape();
for (float a = 0; a < TWO_PI; a += angle) {
float sx = x + cos(a) * radius2;
float sy = y + sin(a) * radius2;
vertex(sx, sy);
sx = x + cos(a+halfAngle) * radius1;
sy = y + sin(a+halfAngle) * radius1;
vertex(sx, sy);
}
endShape(CLOSE);
}

Code for Hue
int barWidth = 50; // increase width of the bar
int lastBar = -1;
void setup()
{
size(640, 640); // change canvas size
colorMode(HSB, height, height, height);
noStroke();
background(0);
}
void draw()
{
int whichBar = mouseY / barWidth; //mouse moves up and down and changes color
if (whichBar != lastBar) {
int barX = whichBar * barWidth;
fill(mouseY, height, height);
rect(barX, 0, barWidth, height);
lastBar = whichBar;
}
}

Analog Output Experimentation

For this analog output experimentation, I learnt how to use a sensor to control an output. I couldn’t really figure how to use the map function though and got confused with the previous voltage divider assignment. However, this exercise would prove useful for my final SPA prank.

Final SPA Documentation: A Rick Roll Box


For the final SPA project, I wanted to use Arduino to create a surprise box prank that would play Never Give You Up by Rick Astley to prank my brother. This is the link to the Arduino project that I would like to replicate: https://create.arduino.cc/projecthub/slagestee/rickroll-box-3c2245 (I just didn’t want an output to be created). 

It took a little bit of finicking as the tone wouldn’t play on the piezo speaker (in an ideal world with no pandemic, I would’ve tried this with an mp3 speaker but couldn’t get one in time). I had to use a toneMelody code to check if the piezo speaker would work and also had to check if each part was working. 

As seen in the video, the tone plays when the photoresistor is uncovered but stops when it is covered. I still have to play with the photoresistor values to have made it less finicky (take in the shadows in the environment). I also took out the potentiometer as it was causing my prank more problems.

To develop this further, it would be nice to attach a servo to it and with it, I would attach a photo of Rick Astley to take the prank even further. 

Here is my code adapted from the tutorial:


#define  a3f    208     // 208 Hz
#define  b3f    233     // 233 Hz
#define  b3     247     // 247 Hz
#define  c4     261     // 261 Hz MIDDLE C
#define  c4s    277     // 277 Hz
#define  e4f    311     // 311 Hz    
#define  f4     349     // 349 Hz 
#define  a4f    415     // 415 Hz  
#define  b4f    466     // 466 Hz 
#define  b4     493     // 493 Hz 
#define  c5     523     // 523 Hz 
#define  c5s    554     // 554 Hz
#define  e5f    622     // 622 Hz  
#define  f5     698     // 698 Hz 
#define  f5s    740     // 740 Hz
#define  a5f    831     // 831 Hz 

#define rest    -1

int piezo = 7;
int led = 9;
int button = 2;
int sensor = A0;

volatile int beatlength = 100; // determines tempo
float beatseparationconstant = 0.3;

int threshold;

int a; // part index
int b; // song index
int c; // lyric index

boolean flag;

// Parts 1 and 2 (Intro)

int song1_intro_melody[] =
{c5s, e5f, e5f, f5, a5f, f5s, f5, e5f, c5s, e5f, rest, a4f, a4f};

int song1_intro_rhythmn[] =
{6, 10, 6, 6, 1, 1, 1, 1, 6, 10, 4, 2, 10};

// Parts 3 or 5 (Verse 1)

int song1_verse1_melody[] =
{ rest, c4s, c4s, c4s, c4s, e4f, rest, c4, b3f, a3f,
  rest, b3f, b3f, c4, c4s, a3f, a4f, a4f, e4f,
  rest, b3f, b3f, c4, c4s, b3f, c4s, e4f, rest, c4, b3f, b3f, a3f,
  rest, b3f, b3f, c4, c4s, a3f, a3f, e4f, e4f, e4f, f4, e4f,
  c4s, e4f, f4, c4s, e4f, e4f, e4f, f4, e4f, a3f,
  rest, b3f, c4, c4s, a3f, rest, e4f, f4, e4f
};

int song1_verse1_rhythmn[] =
{ 2, 1, 1, 1, 1, 2, 1, 1, 1, 5,
  1, 1, 1, 1, 3, 1, 2, 1, 5,
  1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 3,
  1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 4,
  5, 1, 1, 1, 1, 1, 1, 1, 2, 2,
  2, 1, 1, 1, 3, 1, 1, 1, 3
};


int song1_chorus_melody[] =
{ b4f, b4f, a4f, a4f,
  f5, f5, e5f, b4f, b4f, a4f, a4f, e5f, e5f, c5s, c5, b4f,
  c5s, c5s, c5s, c5s,
  c5s, e5f, c5, b4f, a4f, a4f, a4f, e5f, c5s,
  b4f, b4f, a4f, a4f,
  f5, f5, e5f, b4f, b4f, a4f, a4f, a5f, c5, c5s, c5, b4f,
  c5s, c5s, c5s, c5s,
  c5s, e5f, c5, b4f, a4f, rest, a4f, e5f, c5s, rest
};

int song1_chorus_rhythmn[] =
{ 1, 1, 1, 1,
  3, 3, 6, 1, 1, 1, 1, 3, 3, 3, 1, 2,
  1, 1, 1, 1,
  3, 3, 3, 1, 2, 2, 2, 4, 8,
  1, 1, 1, 1,
  3, 3, 6, 1, 1, 1, 1, 3, 3, 3, 1, 2,
  1, 1, 1, 1,
  3, 3, 3, 1, 2, 2, 2, 4, 8, 4
};


void setup()
{
  pinMode(piezo, OUTPUT);
  pinMode(led, OUTPUT);
  pinMode(button, INPUT_PULLUP);
  pinMode(sensor, INPUT);
  attachInterrupt(digitalPinToInterrupt(button), getFaster, FALLING);
  digitalWrite(led, LOW);
  Serial.begin(9600);
  flag = false;
  a = 4;
  b = 0;
  c = 0;
  threshold = analogRead(sensor) + 0;
}

void loop()
{
  //play();
  int sensorreading = analogRead(sensor);
  if (sensorreading < threshold) { // if bright, play
    flag = true;
  }
    else if (sensorreading > threshold) { // if dark, pause
    flag = false;
  }

  //play next step in song
  if (flag == true) {
    play();
  }
}

void play() {
  int notelength;
  if (a == 1 || a == 2) {
    // intro
    notelength = beatlength * song1_intro_rhythmn[b];
    if (song1_intro_melody[b] > 0) {
      digitalWrite(led, HIGH);
      tone(piezo, song1_intro_melody[b], notelength);
    }
    b++;
    if (b >= sizeof(song1_intro_melody) / sizeof(int)) {
      a++;
      b = 0;
      c = 0;
    }
  }
  else if (a == 3 || a == 5) {
    // verse
    notelength = beatlength * 2 * song1_verse1_rhythmn[b];
    if (song1_verse1_melody[b] > 0) {
      digitalWrite(led, HIGH);
      //Serial.print(lyrics_verse1[c]);
      tone(piezo, song1_verse1_melody[b], notelength);
      c++;
    }
    b++;
    if (b >= sizeof(song1_verse1_melody) / sizeof(int)) {
      a++;
      b = 0;
      c = 0;
    }
  }
  else if (a == 4 || a == 6) {
    // chorus
    notelength = beatlength * song1_chorus_rhythmn[b];
    if (song1_chorus_melody[b] > 0) {
      digitalWrite(led, HIGH);
      //Serial.print(lyrics_chorus[c]);
      tone(piezo, song1_chorus_melody[b], notelength);
      c++;
    }
    b++;
    if (b >= sizeof(song1_chorus_melody) / sizeof(int)) {
      //Serial.println("");
      a++;
      b = 0;
      c = 0;
    }
  }
  delay(notelength);
  noTone(piezo);
  digitalWrite(led, LOW);
  delay(notelength * beatseparationconstant);
  if (a == 7) { // loop back around to beginning of song
    a = 1;
  }
}

void getFaster() { // decrease beat length in order to increase tempo
  beatlength = beatlength / 2;
  if (beatlength < 20) { // loop back to original tempo
    beatlength = 100;
  }
}

Final Prank Documentation

Ultimately, I couldn't finish my final prank. I had completed the main part of my project that would alert me when my cat was on the counter by flashing the LED and playing an alarm whenever he covered up the LDR. After this, I tried to connect a servomotor in the hopes that I could use it to drop a small cup of water onto my cat in addition to alerting me.

This didn't go well. When I first researched how to connect the servo motor to my existing project, I was told to connect to GND and 5V. Unfortunately, I was already using 5V to connect to the LDR so I was unsure of what to do. In the hopes of making this work, I tried connecting the servomotor to the other available GND and 3.3V rather than 5V. I learned that this was a mistake, as after I moved away I accidentally grazed the Arduino board and electrocuted my finger.

Overall, I was unable to connect the servomotor but I am still very happy with the alarm system that I created using Arduino. It was a really fun experiment and interesting to watch my cat interact with it. In a way, getting electrocuted felt like karma for trying to splash water on my cat.



The final set up with the servomotor that hurt me


The final