Amanda Bernsohn: @ITP | Images | Statement | CV | Projects

 

For the last two weeks in Rest Of You, we were supposed to be recording information about ourselves - tracking our body's behavior across time. I decided to pay attention to which foot I spend more time depending on more heavily. I suspect that I generally put my weight on my right foot while I am standing still (walking is largely irrelevant to this task).

I started by outfitting a pair of shoes with force sensors in the heels. I wired those up and connected them to analog pins 0 and 1 on my Arduino Diecimila. It was fairly easy to read values from these sensors through the Arduino serial window. I cut up a flip flop for padding the sensors, protecting them and making them slightly less sensitive to force. In Arduino, I subtracted 800 from the analog read values. I did this because my body weight automatically caused the values to shoot up to the maximum (1024). Subtracting the same amount from each value kept the value away from the maximum, while keeping the two sensors the same relative to one another. This all worked out well. Typically, force sensors read quite differently from one another and the values need to be calibrated, but that wasn't really the case with my sensors. Maybe it's because they were bought from the same place at the same time - not really sure. So that was really it for week1 of the process - it was mostly getting the wiring and physical stuff together. Week2 was slightly more complicated.

For week 2, we were to get the values reading in Processing through serial. Ideally we would get the values tracking over time, and run everything with code written in Eclipse. It took me quite a while to get used to the Eclipse interface and figure out which libraries to import for Processing and serial (core.jar, RXTX.jar and serial.jar respectively). Once I sorted that out, and learned how to use the CVS (to grab sample code) I was able to write some code of my own. I wrote a simple program to present two ellipses on screen on load. The diameter of the circles would vary depending on the analog values coming in from the shoes. The idea was to have the circle grow larger as more force is applied and smaller when the force is reduced. Though it was a simple program, getting it to be stable took me forever. From Arduino I sent out the two analog values and the value 255 in bytes in an array of [3]. In processing, the code received the three bytes, threw away the 255 and cycled through an array of [2] to place the values in an X variable and a Z variable (which could have ostensibly be used for anything). Initially, actually, the X and Z (or sensorValues [0] and [1], controlled the X and Y placement of the ellipses on screen). Every other time (at least) that I ran the code, though, the applet would crash. After bringing the code into Eclipse, the error messages became a little more specific and I realized I was overflowing my array on the processing side. Matt Parker helped me stick in a little conditional statement that would prevent that from happening. Here's the basic Eclipse code:

-----------------------------------------------

import processing.core.PApplet;
import processing.serial.Serial;

public class RestOfYou2 extends PApplet{
int x;
int z;
Serial myPort;
int[] sensorValues = new int[2];
int i = 0;
boolean firstContact = false;

public void setup() {
size(1000,1000);
frameRate(30);
smooth();
println(Serial.list());
String portName = Serial.list()[2];
myPort = new Serial(this, portName, 9600);
myPort.write("A");
print("A");
}

public void serialEvent(Serial myPort) {
int inByte = myPort.read();
if ((inByte != 254) && (i<2)){
sensorValues[i] = inByte;
i++;
}
else {
i=0;
}
}

public void draw() {
background(255);
stroke(255,200,200);
fill(255,200,200);
ellipse (260, 500, 60, x);
x = ((sensorValues[0]) * -2);
ellipse (730, 500, 60, z);
z = ((sensorValues[1]) * -2);
println("left: " + sensorValues[0]);
println("right:" + sensorValues[1]);
}
}

-------------------------------------------------

After that, I got my sensor values writing to a file with Dan O.'s file writing code. The txt file saved to my workspace with each value read timestamped.

posted by Amanda @ 5:56 PM,

0 Comments:

Post a Comment

<< Home