I used a flex sensor and a PIC 18F252 for this assignment and drew curves in Processing to visualize the data. The gesture in mind for this assignment was a flex sensor embedded into the handle of a bag. The sensor would indicate when the bag was picked up and when it was put down again.

When the sensor was first attached and put through Tom's original code, there was a significant amount of noise, especially when the side of the sensor with printed text was convex. Putting a pause in the pic program helped.

Assignment 1 Processing Code

Bag Picked Up

Bag Put Down

The problem I had was with Processing. How do you prevent it from writing tons of red lines all at once? I was able to make it so that only two lines show at once in the if statement towards the bottom of my code, but simply putting a background(0) after the curve function simply made the screen black.

Also, I was having troubles getting a "zero" value. Ideally, when the bag is put down, the visualization should be a straight line. Unfortunately, when I tried to zero out the data, the curvature of the line would suffer. Making the curvature larger (I did this by taking the absolute value of the sensor output, subtracting 30 for formatting, and multiplying the result by two) made the "zero" line more curved. Argh.

To zero out the data, you need to know what the sensor's value is at rest, and subtract that from the value that the microcontroller sends to the multimedia computer. That way, when the sensor is at rest, the microcontroller sends 0, and anything above rest sends a positive value.