Description:
I wanted to be able to display the amount of force being applied AND show where my finger is in vertical space. The force distributor I used was a million dollar squishy stress reliever. As my finger presses into the squishy block, it gets closer to the Statue of Liberty in the middle. On Processing, this is visualized by a dollar bill (my finger) getting closer to the center of the circle, which grows as force increases. These two things show me how hard I'm pressing, and corresponds to where my finger is in relation to the center of the stress reliever. For example, if I apply half as much pressure-- the dollar bill will be halfway between the half-grown circle and the middle of the screen. This parallels my finger's position on the squishy dollar bill. I call this animation, "Money on the Dot" because the dollar sign moves toward the dot.
When I apply enough pressure, the dollar bill and the circle merge in the middle of the Processing canvas. I also receive visual feedback about the amount of force I am applying via the Processing/Arduino console and three LEDs, which change in intensity the harder or softer I push. Since the block is rectangular, I experimented with pressing it at various points on the top edge. The force was lower the further I moved from the central point, where the force sensor is. However, it would work as usual when I pressed a little harder than I usually would in the middle of the stress reliever. I originally chose the block because I thought it would transfer force from my finger much more efficiently than other materials. The fact that it was squishy intrigued me as well.
Materials Used:
1x Squishy Milllion Dollar Bill (Stress Reliever)
3x LEDS (Red, Green, Blue)
3x 220 Ohm Resistors
1x 10K Ohm Resistor
1x Force Sensitive Resistor
1x Arduino Uno
Code:
import processing.serial.*;
String headline = "$"; // Money Sign
PFont f; // initialize font
float x; // horizontal location of headline
Serial port;
String buf="";
int cr = 13; // ASCII return == 13
int lf = 10; // ASCII linefeed == 10
void setup() {
size(800,440);
frameRate(60);
smooth();
background(40, 40, 40);
noStroke();
f = createFont("Arial",16,true); // Arial, 16 point, anti-aliasing on
x = width; // initializing headline off-screen to the right
/*
Run the code once with this print statement to see a list of available serial ports.
Make a note of the number next to the port you'd like to use
*/
println(Serial.list());
/* Once you know the number of the port you want to use Replace the "0" in the code below
with the port number. For instance, if you wanted to use port number 4 in the list, then
the code should say: port = new Serial(this, Serial.list()[4], 9600);
*/
port = new Serial(this, Serial.list()[0], 9600);
}
void draw() {
}
void keyPressed() {
if(key == ' ') {
background(40,40,40); // erase screen
}
else {
background(40,40,40); // erase screen
}
}
// draw growing ball and compute dollar sign animation
void drawball(int x, int y, int r) {
for (int i=0; i<100; i++ ) {
textFont(f,80);
textAlign(CENTER);
text(headline,x,r,240);
ellipse(x,y,r,r);
}
}
// called whenever serial data arrives
void serialEvent(Serial p) {
int c = port.read();
/* this print statement will allow you to see whether or not Processing can "hear" anything that
Arduino is sending. It should print all the changing values of the FSR or Photocell in your circuit
If nothing is printing, you probably picked the wrong serial port.
*/
println(c);
if (c != lf && c != cr) {
buf += char(c);
}
if (c == lf) {
int val = int(buf);
println("val="+val);
drawball(400,220,val);
buf = "";
background(40,40,40); // erase screen
}
}
- Login to post comments