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. A Soft Plastic Heart and Digital Ball Reflection

Project Members: 
Seung Wan Hong

Desription

Through one potentiomenter and FSRs, I control the brightness and blinking of 2LEDs. I also find material, a soft plastic model, to control perssure for ESRs effectively. On processing, I tried to control digital ball's reflection.

Components

1LED, a ping-pong ball as a diffuser, a red soft plastic heart, FSRs, 1 petentiometer, 9wires, Arbuino Board, Bread Board

Arduino Codes

int pot1Pin = 0;   // select the input pin for the FSRs, Brightness
int pot2Pin = 1;   // select the input pin for the potentiometer1, Blinking
int pot1Val = 0;   // variable to store the value coming from pot 1
int pot2Val = 0;   // variable to store the value coming from pot 2
int redPin = 9;   //  the pin for the red LED
int greenPin = 10; // the pin for the green LED

void setup() {
   pinMode(redPin, OUTPUT);  // declare the led1Pin as an OUTPUT
   pinMode(greenPin, OUTPUT);  // declare the led2Pin as an OUTPUT
}
void loop() {
   pot1Val = analogRead(pot1Pin);   // read the value from pot 1, between 0 - 1024, for dimming
   pot2Val = analogRead(pot2Pin);   // read the value from pot 2, between 0 - 1024, for blinking
   analogWrite(redPin, pot1Val/4); // dim LED to value from pot1
   analogWrite(greenPin, pot1Val/4);
   delay(pot2Val);                  // stop the program for some time, meaning, LED is on for this time
   analogWrite(redPin, 0);         // dim LED to completely dark (zero)
   analogWrite(greenPin, 0);
   delay(pot2Val);                  // stop the program for some time, meaning, LED is OFF for this time

Processing

import processing.serial.*;

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

void setup() {
  size(300, 300, P3D);
  noStroke();
  colorMode(RGB, 1);
  fill(0.4);
  port = new Serial(this, portname, 9600);
}

void draw() {
  background(0);
  translate(width / 2, height / 2);
  // Set the specular color of lights that follow
  lightSpecular(3, 3, 3);
  directionalLight(0.8, 0.8, 0.8, 0, 0, -1);
  float s = fsr / float(width);
  specular(s, s, s);
  sphere(50);
}
// 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 = "";
  }
}

Video

http://www.youtube.com/watch?v=-V8AQx_d-40


AttachmentSize
After pressure.jpg166.36 KB
Before pressure.jpg177.41 KB

Powered by Drupal - Design by Artinet