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: 
Kenghao Chang

Components

  • FSR
  • Photocell
  • 10k resistor
  • LEDs
  • Arduino board
  • Bread board
  • Wires

In lab exercise

For the in-lab exercise, i have tried plugging in FSR and photo cells on the breadboard. Using the code for Lab-3, I can control the brightness and blinking rate with those two sensors. Here arethe demo vidoe and pictures.

video1, video2

lab4-1-1

lab4-1-2

Homework-1 Visualizaiton

In the first homework of creating visualization, i modified the sample code for processing and made the java applet visualize how much pressure you put on the FSR. Processing code would draw circles on random coordinates, with sizes based on FSR readings (the larger the pressure on FSR, the larger the circles).

Code on Arduino

int potPin = 0; // select the input pin for the potentiometer
int ledPin = 10; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
}
void loop() {
val = analogRead(potPin); // read the value from the sensor, between 0 - 1024
Serial.println(val/4, DEC);
analogWrite(ledPin, val/4); // analogWrite can be between 0-255
}

Code on Processing

import processing.serial.*;

// Change this to the portname your Arduino board
String portname = "COM4"; // or "COM5"

Serial port;
String buf="";
int cr = 13; // ASCII return == 13
int lf = 10; // ASCII linefeed == 10

int maxNum = 50;
int num = 0;
void setup() {
size(600,600);
frameRate(10);
smooth();
background(40,40,40);
noStroke();
port = new Serial(this, portname, 9600);
}

void draw() {
}

void keyPressed() {
}

// draw a ball
void drawball(int x, int y, int r) {
ellipse(x,y, r,r);
}

// called whenever serial data arrives
void serialEvent(Serial p) {
int value;
if (port.available() > 0) {
String myString = port.readStringUntil(lf);
if (myString != null) {
//print(myString.substring(0, myString.length()-2));
value = int(myString.substring(0, myString.length()-2));
//value = int(myString);

int sign = 1;
println(""+value);
if (value > 0) {

int x = int(random(0,width));
int y = int(random(0,height));
if (int(random(0,1)) == 0)
sign = -1;
drawball(x,y,value+sign*int(random(0,10)));

if (++num == maxNum) {
background(40,40,40);
num = 0;
}
}
}
}
}

Demo

video

Homework-2 Mechanical

Have you forgotten to take your ID with you after you finish photocoping it? That happens a lot. We have discussed this and we thought this is actually an usability problem. A scanner or copy machine should warn you if you leave your ID there.

Simpy attach a FSR on the top cover of a scanner or a copy machine. When the FSR recevies force (the cover is closed) for a significant amount of time after an user presses the print button, RING the bell and warn the user to take the copied paper! It's similar to the mechanism of microwave; after it finishes cooking for a while, it beeps!

scanner


Powered by Drupal - Design by Artinet