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!


Revision of Assignment 4. Move 3D Camera with FSR from Thu, 09/27/2007 - 09:44

Project Members: 
Seung Wook Kim

 

* To Instructors: Because of high fever, I won't be able to come to the class today. I will also improve the assignment below as soon as I get better. Thanks for your consideration. - Seung Wook Kim 

 

[Description]

- Using FSR, move the camera in the 3D space up and down.

 

[Components]

- FSR X 1

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

- LED X 1

 

[Processing Code]

import processing.serial.*;

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

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

void draw(int val) {
  lights();
  background(0);
  // Change height of the camera with mouseY
  camera(30.0, val, 220.0, // eyeX, eyeY, eyeZ
         0.0, 0.0, 0.0, // centerX, centerY, centerZ
         0.0, 1.0, 0.0); // upX, upY, upZ
  noStroke();
  box(90);
  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) {
    int val = int(buf);
    println("val="+val);
    draw(val);
    buf = "";
  }
}


Powered by Drupal - Design by Artinet