Description
This fourth lab was an introduction to the language Processing 2.0. This java based coding allows for use of computer graphics with different external commands. We were charged with the task of using either a Force Resistive Sensor (FSR), Potentiometer or Light Sensors to control on an screen graphic.
I chose to use a single FSR to manipulate the placement of a Bezier curve on screen. With no input, the screen is blank, but as a force is felt, the curve moves around the screen on a planned path and the color of the curve intensifies. The hardest part of this lab was to get the correct coding for the FSR input. Once I understood the theory behind the input and corrected some errors in my code it was easy to manipulate an on screen graphic.
To increase the surface area of the FSR I chose a ripe (conductive) banana!
Components Used
1 - Arduino Uno
1 - Mini Breadboard
1 – 10 KΩ Resistor
1 – Force Sensitive Resistor
1 – Banana
Code
Arduino Code
/*
Bigazzi Lab 4
*/
int push=0;
int val;
void setup() {
Serial.begin(9600);
pinMode(push,INPUT);
}
void loop() {
val = analogRead(push);
Serial.println(val);
delay(60);
}
Processing Code
/*
Bigazzi Lab 4
Force Sensitive Resistor
*/
import processing.serial.*;
Serial port;
float brightness = 0;
void setup () {
size(650,460);
stroke(255);
noFill();
port = new Serial(this, "/dev/tty.usbmodem1421", 9600);
port.bufferUntil('\n');
}
void draw() {
background(0);
for (int i = 0; i < 200; i += 20) {
stroke(brightness,0, brightness);
bezier(brightness-(i/2.0), 40+i, 410, 20, 440, 300, 240-(i/16.0), 300+(i/8.0));
}
}
void serialEvent(Serial port) {
brightness = float(port.readStringUntil('\n'));
println(brightness);
}
- Login to post comments