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!


Assignment 4. Squeeze 3D Cube & Sphere with FSR

Project Members: 
Seung Wook Kim

[Description]

- Using FSR, change the size of cube in the 3D space.

- Using a plastic ball as an interface to squeeze the 3D sphere.

 

[Components]

- FSR X 1

- Resistor (R-R-B-G) X 1

- LED X 1

 

[Processing Code]

import processing.serial.*;

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

void setup() {
  size(400, 400, P3D);
  fill(204);
  port = new Serial(this, portname, 9600);
}

void draw() {
  drawSphere(fsr);
}

void drawSphere(int s) {
  lights();
  background(0);
  camera(30.0, 120.0, 180.0, // eyeX, eyeY, eyeZ
         0.0, 0.0, 0.0, // centerX, centerY, centerZ
         0.0, 1.0, 0.0); // upX, upY, upZ
  noStroke();
  sphere(80 - s/4); // Change the size of sphere with FSR
  stroke(255);
  line(-100, 0, 0, 100, 0, 0);
  line(0, -100, 0, 0, 100, 0);
  line(0, 0, -100, 0, 0, 100);
}

// called whenever serial data arrives
void serialEvent(Serial p) {
  int c = port.read();
  if (c != lf && c != cr) {
    buf += char(c);
  }
  if (c == lf) {
    fsr = int(buf);
    println("fsr="+fsr); 
    buf = "";
  }
}



Assign 04

Assign 04


Powered by Drupal - Design by Artinet