Lab 4

Visualization

Very minimal visualization of the sensorValue as an ellipse of radius 3 times the FSR input value

 

Code

/*
 * Arduino Ball Paint
 * (Arduino Ball, modified 2008)
 * ----------------------
 *
 * Draw balls randomly on the screen, size controlled by a device
 * on a serial port.  Press space bar to clear screen, or any
 * other key to generate fixed-size random balls.
 *
 * Receives an ASCII number over the serial port,
 * terminated with a carriage return (ascii 13) then newline (10).
 *
 * This matches what Arduino's " Serial.println(val)" function
 * puts out.
 *
 * Created 25 October 2006
 * copyleft 2006 Tod E. Kurt <tod@todbot.com
 * http://todbot.com/
 */
import processing.serial.*;
// Change this to the portname your Arduino board
String portname = "/dev/tty.usbmodemfa141"; // or "COM5"
Serial port;
String buf="";
int cr = 13;  // ASCII return   == 13
int lf = 10;  // ASCII linefeed == 10
float xPos = width/2; // horizontal position of the graph
float yPos = height/2;

void setup() {
  size(400,300);
  frameRate(7);
  smooth();
  background(40,40,40);
  noStroke();
  port = new Serial(this, portname, 9600);
}
void draw() {
}
void keyPressed() {
  if(key == ' ') {
    background(40,40,40);  // erase screen
  }
}

// called whenever serial data arrives
void serialEvent(Serial p) {


  int sensorValue = port.read();
      sensorValue *= 3;

float inByte = map(sensorValue, 0, 1023, 0, height);
 
 // draw the ellipse:
 stroke(127,34,255);
 ellipse (xPos + sensorValue/2, yPos + sensorValue/2, sensorValue, sensorValue);
 
 // at the edge of the screen, go back to the beginning:
 if (xPos >= width) {
 xPos = 0;
 background(0);
 }
 else {
 // increment the horizontal position:
 xPos++;
 }
 
}

 

Mechanical

Materials:

- 1 small plastic ziploc bag

- 7 pieces of cotton ball

- Scotch tape

Designed a cushion pad for tapping out rhythmic input codes. Used extra cotton padding to even distribute the force of the fingers pressing on the FSR. To be further developed for midterm and final project as input pads for navigating a 'storyball' whereby the amount of pressure indicates how far in time the playhead should start playing an audio stream.

 

 

SerialBall2
SerialBall1
CushionPad2
CushionPad1
0
Your rating: None