Description:
I decided to use the FSR as an input measurement for stress of a person, and then used it shower them with LOVE! The user will press the stress ball really hard if he is under stress and then the visualization which is written in Processing will fill his screen with hearts. The hearts get darker and bigger as the stress increases. I also experimented with a doll, because babies clench dolls really hard when they play with them and this can be used to show their parents a visualization of their activity.
Components:
1 Breadboard
1 Arduino Uno
1 Resistors 10K ohm
1 Resistors 220 ohm
1 LED Red
1 FSR
1 stress ball
And whole bunch of wires.
Code:
/* Draws hearts on screen based on the force applied on a stress ball or a doll.
*
* 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.usbserial-AM01QP9F"; // or "COM5"
Serial port;
String buf="";
int cr = 13; // ASCII return == 13
int lf = 10; // ASCII linefeed == 10
PShape heart;
void setup() {
size(800,800);
frameRate(30);
smooth();
background(40,40,40);
noStroke();
port = new Serial(this, portname, 9600);
heart = loadShape("heart.svg");
}
void draw() {
}
// draw heart and scale
void drawheart(int val) {
heart.disableStyle();
fill(247,181,247);
stroke(255);
shape(heart, int(random(0,width)), int(random(0,height)), val, val);
if (val>80 && val<166) {
heart.disableStyle();
fill(243,90,90);
shape(heart, int(random(0,width)), int(random(0,height)), val, val);
}
// Draw a very dark large heart when user is uses maximum force
else if (val>166) {
background(40,40,40);
noStroke();
heart.disableStyle();
fill(241,66,66);
shape(heart, int(random(0,width)), int(random(0,height)), 600, 600);
}
else {
heart.disableStyle();
fill(254,247,254);
shape(heart, int(random(0,width)), int(random(0,height)), val, val);
}
}
// called whenever serial data arrives
void serialEvent(Serial p) {
int c = port.read();
if (c != lf && c != cr) {
buf += char(c);
}
if (c == lf) {
int val = int(buf);
println("val="+val);
if (val>0){
drawheart(val);
}
}
}
- Login to post comments