ERASURE MEMORY

Michael Clemow
Seanita Tolliver
Jody Zellen

 
INITIAL IDEAS PROTOTYPE 1 TECHNICAL INFO ITERATIONS FUTURE
 



THE SENSORS:

FSR:
FSR:
ACCELEROMETER:



THE PROCESSING CODE

import processing.serial.*;
import processing.video.*;

Serial port;
Capture vidCapture;
boolean pictureTaken = false;

int side;
int bottom;
int accelX;
int accelY;
int accelZ;

void setup() {
  size(640,480);
  smooth();
  background(255);
  
  vidCapture = new Capture(this,640,480,15);
  
  // Print a list of serial ports so we can see what they are called
  println(Serial.list());
  port = new Serial(this, Serial.list()[0], 9600);  // if this doesn't work, check the output of the line above
  port.write(65);  // send a byte to the microcontroller to start communication
  println("Starting communication...");
}

void draw() {
  //background(255);
  //println("X: " + accelX + " Y: " + accelY + " Z: " + accelZ + " S: " + side + " B: " + bottom);
  if(pictureTaken) {
    // pick random point
    int x = int(random(vidCapture.width));
    int y = int(random(vidCapture.height));
    int loc = x + y*vidCapture.width;
    
    frameRate(4);
    
    // look up color in video
    loadPixels();
    float r = red(vidCapture.pixels[loc]);
    float g = green(vidCapture.pixels[loc]);
    float b = blue(vidCapture.pixels[loc]);
   
    // color enhancement
    if(r > 100) { r = 255; }
    if(r < 70) { r = 0; }
    if(g > 100) { g = 255; }
    if(g < 70) { g = 0; }
    if(b > 100) { b = 255; }
    if(b < 70) { b = 0; }
    
    // draw an ellipse or something at that point with that color
    fill(r,g,b);
    
    if(accelY > 395) {  // drawing with strokes
      strokeWeight(side/100);
      stroke(0);
    } else {  // drawing without strokes
      noStroke();
    }
    
    rect(x,y,accelX/10,bottom/10);
  }
}

void serialEvent(Serial port) {
  String stringFromArduino = port.readStringUntil(9);  // read until the end, e.g. "9" or a tab character
  if (stringFromArduino != null) {
    //println("String from Arduino: " + stringFromArduino);  // DEBUG
    String[] parts = stringFromArduino.split(",");  // We know it's a comma because we sent "44" from Arduino.
    //println(parts.length);
    // assign our variables
    accelX = int(parts[0]);  // we know this is first because we sent it first.
    accelY = int(parts[1]);  // int() casts the string chunk into a integer type.
    accelZ = int(parts[2]);
    side = int(parts[3]);
    bottom = int(parts[4].trim());  // use .trim() to get rid of the tab character.
    // readStringUntil apparently includes what you're reading until (in this case, the tab character)
    
    port.write(65);  // tell Arduino we're ready for more.
  }
}

void keyPressed() {
  if(key == 'c') {
    println("Taking a picture");
    if(vidCapture.available()) {
      vidCapture.read();
      pictureTaken = true;
    }
  }
  if(key == 'd') {
    if(pictureTaken) {
      image(vidCapture,0,0,640,480); // debug string to test framing
    }
  }
  if(key == 'r') {
    background(255);
  }
  if(key == 's') {
    pictureTaken = !pictureTaken;
  }
}



The ARDUINO CODE


/*
 * Eraser Memory Device Code
 */

long FSRSide = 0;
long FSRBottom = 0;
long accelX = 0;
long accelY = 0;
long accelZ = 0;

int FSRPinSide = 0;
int FSRPinBottom = 1;
int accelPinX = 2;
int accelPinY = 3;
int accelPinZ = 4;

void setup() {
  // open serial communications at 9600 bps
  Serial.begin(9600);
  
  // Let's you know when you the Arduino code is running by making blinky
  pinMode(13, OUTPUT);
  for(int i=0;i<4;i++) {
    digitalWrite(13, HIGH);
    delay(300);
    digitalWrite(13, LOW);
    delay(300);
  }
}

void loop() {
  if(Serial.available() > 0) {
    // read x,y,z value pins
    for(int i=0;i<10;i++) {
      accelX = accelX + analogRead(accelPinX);
      accelY = accelY + analogRead(accelPinY);
      accelZ = accelZ + analogRead(accelPinZ);
      FSRSide = FSRSide + analogRead(FSRPinSide);
      FSRBottom = FSRBottom + analogRead(FSRPinBottom);
    }

    // prints "X,Y,Z,Side,Bottom" Dano's Text-Style
    Serial.print(accelX/10, DEC);
    Serial.print(44, BYTE);
    Serial.print(accelY/10, DEC);      
    Serial.print(44, BYTE);
    Serial.print(accelZ/10, DEC);
    Serial.print(44, BYTE);
    Serial.print(FSRSide/10, DEC);
    Serial.print(44, BYTE);
    Serial.print(FSRBottom/10, DEC);
    
    // if you're not using Windows, use something other than 10 or 13 here to signal the end of the line
    Serial.print(9, BYTE);

    // reset variables back to zero
    accelX = 0;
    accelY = 0;
    accelZ = 0;
    FSRSide = 0;
    FSRBottom = 0;
  }
}