Announcements

November 24, 2007
Reading for November 27th, are now posted. Enjoy!

October 2, 2007
To upload your thoughtless acts, create a new assignment page like any other lab. You'll see "Thoughtless Acts" listed as one of the assignment options.

May 24, 2008
This site has been archived and is no longer editable. Stay tuned for the next version, coming in the fall!


Lab 4

Project Members: 
Eun Kyoung Choe

Description


By pressing the FSR sensor, you can create an abstract drawing full of circles. As you press the FSR sensor harder, the radius of a circle becomes larger, color of the circle becomes brighter. (black<->white) X and y coordinates are randomly chosen. You can start over if you press the space key.


Hardware Components Used

3 LED
4 Resistors
1 FSR
Arduino Board
Breadboard
Wires

Arduino Code

/*
* 09/26/07
* Tangible User Interfaces
* Lab 4 Sensors: Force sensitive resistors and photocells
* Eun Kyoung Choe
*/

// variables for input pin and control LED
int analogInput = 3;
int LEDpin1 = 13;
int LEDpin2 = 12;
int LEDpin3 = 11;
// variable to store the value
int value = 0;
// a threshold to decide when the LED turns on
int threshold = 512;
void setup(){

// declaration of pin modes
pinMode(analogInput, INPUT);
pinMode(LEDpin1, OUTPUT);
pinMode(LEDpin2, OUTPUT);
pinMode(LEDpin3, OUTPUT);
// begin sending over serial port
beginSerial(9600);
}

void loop(){
// read the value on analog input
value = analogRead(analogInput);

// if value greater than threshold turn on LED
if (value < threshold){
digitalWrite(LEDpin1, LOW);
digitalWrite(LEDpin2, LOW);
digitalWrite(LEDpin3, LOW);
}

else{
digitalWrite(LEDpin1, HIGH);
digitalWrite(LEDpin2, HIGH);
digitalWrite(LEDpin3, HIGH);
}
// print out value over the serial port
printInteger(value);

// and a signal that serves as seperator between two values
printByte(10);

// wait for a bit to not overload the port
delay(10);
}

Processing Code

/*
* 09/26/07
* Tangible User Interfaces
* Lab 4 Sensors: Force sensitive resistors and photocells
* Eun Kyoung Choe
*
* Reads the values which represent the state of a FSR sensor
* from the serial port and draws a graphical representation.
*/

// importing the processing serial class
import processing.serial.*;

// definition of window size and framerate
int xWidth = 500;
int yHeight = 500;
int fr = 30;

// attributes of the display
boolean output = false;
// variables for serial connection, portname and baudrate have to be set
Serial port;
String portname = "/dev/tty.usbserial-A4001nXx";
int baudrate = 9600;
int value = 0;
String buf="";
int value1 = 0;

// variables to draw graphics
int x, y, cursorSize;
int cnt = 6;
// hit the space key and erases the screen
void keyPressed(){
if (key == ' '){
background(153);
}
}

void setup(){
// set size and framerate
size(xWidth, yHeight);
background(153);
frameRate(fr);
// establish serial port connection
port = new Serial(this, portname, baudrate);
println(port);
noStroke();
smooth();
}

void drawLDRState(){
cnt = int(random(1,5));
cursorSize = 5 + cnt*(value1/20);
x=int(random(0,500));
y=int(random(0,500));
float gray = value1/4;
fill(gray,120);
ellipse(x,y,cursorSize,cursorSize);
}

void serialEvent(int serial){

if(serial!=10) {
buf += char(serial);
} else {
value1 = int(buf);
buf="";
}
if(output) println("LDR: "+value1);
}

void draw(){
while(port.available() > 0){
value = port.read();
serialEvent(value);
}
drawLDRState();
}

 

Mechanical Part

I
love drip coffee, but I have to follow some steps to make a good cup of
coffee using a cone dripper. One of the steps is to
use the right amount of the coffee, so I use a Tablespoon to measure
the coffee ground especially when I make more than one cup. I thought
it might be convenient if FSR is attached to the bottom of the cone
filter, can measure the weight of the coffee ground so that tells me
whether I use the right amount of the coffee ground by color of the
LED.The color of the LED changes proportionate to the amount of the
coffee ground. When the weight reaches to every two Tablespoon (=serves
for one person), LED blinks.

 

Photo
lab4pressdripcoffee


Powered by Drupal - Design by Artinet