Description
For this assignment, I decided to combine both parts into a single stress-buster contraption. I felt this would be apt now that we've reached the middle of the semester and are in the depths of homework and projects.
For the mechanical part, I covered the FSR in bubble-wrap to distribute the force. The bubble wrap I used had huge bubbles, where a bubble is the size of the resistor, so it works as well as a sponge. i would've liked to use a balloon to simulate a punching bag on the outside, but I made use of a small Ziploc bag instead (as I didn't have a balloon at home). I also stuck a post-it that said 'POW' onto this to the impression of punching. For me, POW worked. But for someone else, this can be substitued with a symbol of something they'd like to punch to relieve their stress.
For the visualization, I modified the Arduino Ball code to create a visualization of the word 'POW' that overlays with every jab at the FSR. The output of 'POW' gives you a satisfying feeling everytime you punch / flick / press the FSR.
Components
1x Arduino Uno
1x Breadboard
1x Macbook Pro
8x wires
2x 220 ohm resistors
1x LED light
Code
Arduino Code
/*
* Resistive Sensor Input
* Takes the input from a resistive sensor, e.g., FSR or photocell
* Dims the LED accordingly, and sends the value (0-255) to the serial port
*/
int sensorPin = 0; // select the input pin for the sensor
int ledPin = 13; // select the output pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
}
void loop() {
val = analogRead(sensorPin); // read the value from the sensor, 0-1023
analogWrite(ledPin, val/4); // analogWrite (dimming the LED) can be between 0-255
delay(250);
Serial.println(val/4); // writing the value to the PC via serial connection
delay(50); // rest a little...
Processing Code
/*
* Arduino Ball Paint
* (Modified 2013)
* ----------------------
*
* 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.usbmodem1421"; // or "COM5"
Serial port;
String buf="";
int cr = 13; // ASCII return == 13
int lf = 10; // ASCII linefeed == 10
void setup() {
size(350,350);
frameRate(10);
smooth();
background(40,40,40);
noStroke();
port = new Serial(this, portname, 9600);
}
void draw() {
}
void keyPressed() {
if(key == ' ') {
background(40,40,40); // erase screen
}
else {
int x = int(random(0,width));
int y = int(random(0,height));
}
}
// draw pow
void punch(int val){
float i =random(100);
float j =random(50);
stroke(255);
fill(255,i,j);
if (val > 0){
val = int (val/10);
beginShape();
vertex(20*val, 10*val);
vertex(60*val, 30*val); //1
vertex(80*val, 20*val); //2
vertex(60*val, 40*val); //3
vertex(90*val, 50*val); //4
vertex(70*val, 60*val); //5
vertex(90*val, 90*val); //6
vertex(60*val, 60*val); //7
vertex(50*val, 80*val); //8
vertex(40*val, 60*val); //9
vertex(20*val, 50*val); //11
vertex(40*val, 50*val); //12
vertex(10*val, 40*val); //13
vertex(40*val, 35*val); //14
vertex(20*val, 10*val); //14
endShape(CLOSE) ;
fill(255);
// int textsize = int(14*val);
// textSize(textsize);
text("POW!",45*val,45*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);
if (val != 0) {
println("val="+val);
}
int x = int((width/2));
int y = int((height/2));
// drawball(x,y,val);
punch(val);
buf = "";
}
}
}
Video Link
https://www.facebook.com/photo.php?v=10153318008250065&set=vb.611345064&type=2&theater
- Login to post comments