lab assignment_04

Submitted by njohn on Tue, 02/26/2013 - 23:53
//description

I wanted to create a visualization that would react to user input in ways that either generated stress or calm, and then correlate these graphic conditions to a desired behavior.  I chose a flat-topped hyperbolic paraboloid to simulate a sort of balance board.

When the user successfully balances, they see a calm blue-green orb.  As they begin to lose their balance, the orb shrinks and the background becomes a bright red.

 

//materials

1 x arduino uno

1 x breadboard

1 x force sensitive resistor

1 x 10k ohm resistor

1 x force diffuser

 

//code

 

 // balance ball colors
 
 // Created 26 Feb 20013
 // based on code by Tom Igoe
 
 import processing.serial.*;
 
 Serial myPort;            // The serial port
 int xPos = 1;             // horizontal position of the graph
 int val = 0;
 
 void setup () { 
 size(800 , 800);          // set the window size:
 
 
 println(Serial.list());    // List all the available serial ports
 
 myPort = new Serial(this, Serial.list()[4], 9600);
 // don't generate a serialEvent() unless you get a newline character:
 myPort.bufferUntil('\n');
 // set inital background:
 background(51);
 }
 void draw () {
 // everything happens in the serialEvent()
 }
 
 void serialEvent (Serial myPort) {
 // get the ASCII string:
 String inString = myPort.readStringUntil('\n');
 
 if (inString != null) {
 inString = trim(inString);
 
 int inByte = int(inString); 
 
 int val = 255 - inByte;
 
 background(val, 0, 0);
 
 draw () ;
   fill(0, 240, 240);
   ellipse(400, 400, inByte, inByte);
 
 }
 }
 
 
*/ arduino code
 
/*
 * Resistive Sensor Input
 * Takes the input from a resistive sensor, e.g., FSR or photocell
 * Dims the LED accordingly, and sends the value (0-255) to the serial port
 */
 
int sensorPin = 0;  // select the input pin for the sensor
int val = 0;        // variable to store the value coming from the sensor
 
void setup() {
  Serial.begin(9600);
}
 
void loop() {
  val = analogRead(sensorPin); // read the value from the sensor, 0-1023
  Serial.println(val);       // writing the value to the PC via serial connection 
  delay(50);                   // rest a little...
}
 
/*
 
photo 1.JPG
photo 2.JPG
photo 3.JPG
0
Your rating: None
Drupal theme by Kiwi Themes.