Lab 4 FSR and graphics

Description:

I thought there were two parts to the assignment: 1. making a graphic that reacts to FSR

2. making a reactive graphic that coincides w a pressure sensor application.

so for 2.

I thought of making a graphic that can tell you if you are pressing on your cellphone and hopefully warn you before you crack it.

Components:

  • Arduino Uno
  • Breadboard
  • 1 force sensor
  • 1 220Ω resistors
  • 1 10Ω resistor
  •  wires

Part 1 graphic is a sort of abstract pattern of lines and circles. I thought it was interesting that the lines rotate when you apply serialVal to the variables.

— processing code —

String portname = “/dev/cu.usbmodem1421”; // or “COM5″
Serial port;
String buf=””;
int cr = 13; // ASCII return == 13
int lf = 10; // ASCII linefeed == 10

int serialVal = 0;

void setup() {
size(640,640);
frameRate(10);
smooth();
background(40,40,40);
noStroke();
port = new Serial(this, portname, 9600);
}

void draw() {
// erase the screen
background(100, 40, 40);

// draw the ball
noFill();
stroke(200);
strokeWeight(.5);
line(150,serialVal,serialVal,100);
line(100,serialVal,serialVal,150);
ellipse(serialVal, serialVal, 50 + serialVal, 50 + serialVal);

strokeWeight(1);
line(200,serialVal,serialVal,75);
line(75,serialVal,serialVal,200);
ellipse(serialVal, serialVal, serialVal, serialVal);

strokeWeight(2);
line(250,serialVal,serialVal,55);
line(55,serialVal,serialVal,250);
ellipse(serialVal, serialVal, serialVal -50, serialVal – 50);

strokeWeight(2.5);
line(300,serialVal,serialVal,35);
line(35,serialVal,serialVal,300);
ellipse(serialVal, serialVal, serialVal -150, serialVal – 150);

strokeWeight(3.5);
line(500,serialVal,serialVal,15);
line(15,serialVal,serialVal,500);

}

// called whenever serial data arrives
void serialEvent(Serial p) {
int c = port.read();
if (c != lf && c != cr) {
buf += char(c);
}
if (c == lf) {
serialVal = int(buf);
println(“potValue=”+serialVal);
buf = “”;
}
}

+ + + + +

Part 2 graphic I can’t really create an actual connection between the cellphone and the graphic so I made a visual mockup on computer monitor where I overlay the Processor sketch window over a photo of a cellphone.

if you press on the center of the phone, the screen turns from black to red (the universal warning color)  and the text

“—hey— watch it.” comes up

—processing code—

String portname = “/dev/cu.usbmodem1421”; // or “COM5″
Serial port;
String buf=””;
int cr = 13; // ASCII return == 13
int lf = 10; // ASCII linefeed == 10

int serialVal = 0;

void setup() {
size(325,560);
frameRate(10);
smooth();
background(40,40,40);
noStroke();
port = new Serial(this, portname, 9600);
}

void draw() {

background(serialVal, serialVal-155, serialVal-155);
stroke(255,0,0);
fill(serialVal, serialVal, serialVal);
textSize(15);
text(“—hey—”, 130,260);
text(“watch it.”, 130, 300);

}

// called whenever serial data arrives
void serialEvent(Serial p) {
int c = port.read();
if (c != lf && c != cr) {
buf += char(c);
}
if (c == lf) {
serialVal = int(buf);
println(“potValue=”+serialVal);
buf = “”;
}
}

 

 

 

Leave a Reply