FSR and visualization

Submitted by sebarness on Tue, 02/26/2013 - 01:18

 

Objective: I have hooked up my FSR to light up a LED and output a visualization graph using Processor. The graph makes higher lines according to amount of force on sensor and captures the time of force on the sensor as well. At the edge of the screen it will go back to the beginning. For my mechanical construction I constructed a hand that you push in order to apply force to the sensor. I thought it would be interesting to create an iconic symbol for my FSR.
 
Materials:
-FSR
-photocell
-led
-wires
-resistors
-breadboard
 
Software : Processor
 
//got hep from Arduino documentation
import processing.serial.*;
// Change this to the portname your Arduino board
String portname = "/dev/tty.usbmodemfd121"; // or "COM5"
Serial port;
 
int xPos = 1;
void setup(){
  size(600,600);
  frameRate(10);
  smooth();
  background(40,50,40);
  noStroke();
 
  port = new Serial(this, portname, 9600);
}
void draw() {
}
 
void serialEvent (Serial port) {
String inString = port.readStringUntil('\n');  //read serial until new line
 
if (inString != null) {
float fsr = float(inString);
fsr = map(fsr, 0, 1023, 0, height);  //map instring value
 
// draw the line:
 stroke(127,34,255);
 line(xPos, height, xPos, height - fsr);
 
 // at the edge of the screen, go back to the beginning:
 if (xPos >= width) {
 xPos = 0;
 background(0); 
 } 
 else {
 // increment the horizontal position:
 xPos++;
 }
 }
}
fsrgraphh.jpg
photo (10).JPG
0
Your rating: None
Drupal theme by Kiwi Themes.