HOME
ASSIGMENTS
CONTACT
DOWNLOAD FILES
FINAL
PROJECT
Interface and Application Programming
In this assignment we have to develop an interface that responds to an input device or to be linked to an output device .
In this ocation, I used the Fabduino I built for the OUTPUT DEVICE assigment to send information to the computer through a serial port.
Then burn a program that filters the signal to piezoelectric and map it to translate it into visual information , I used processing for that , processing allowed me to generate a relationship between generative geometry and sound.
The Videos
Codes
ARDUINO
int datoRead, datoWrite=0;
void setup() {
Serial.begin(9600);
pinMode(7, OUTPUT);
}
void loop() {
datoRead = analogRead(A0);//declara el pin de entrada
datoWrite= map(datoRead, 0,10,0,255); //mapeodel rango de la señal con el rango de tonos
Serial.write(datoWrite);//monitoreo de datos de entrada
if (datoRead>10){//condición
tone(7,datoWrite);}//entonces emite tono
if (datoRead>10){//condición
delay(1000);//entonces el tono dura este tiempo
}
noTone(7);//si la señal es menor a 10 no hay tono
}
PROCESSING
import processing.serial.*;
int val = 0; // To store data from serial port, used to color background
Serial port; // The serial port object
float a;
float b;
float h, x, y;
void setup() {
size(1330, 700);
port = new Serial(this, Serial.list()[0], 9600);
a = width/2;
b = height/2;
background(0);
}
void draw() {
println(val);
x = val;
y = 0.0049*x*x + x*0.001 + 5 ;
stroke(255);
line(a, b, x+width/2, y); // arriba derecha
line(a, b, width/2-x, y); //arriba izquierda
line(a, b, x+width/2, height-y);//abajo derecha
line(a, b, width/2-x, height-y); // abajo izquierda
line(x+width/2, y, width/2-x, y); // arriba
line(x+width/2, height-y, width/2-x, height-y); // abajo
line(x+width/2, b, width/2-x, b); // centro
line(x+width/2, b, a, y );
line(width/2-x, b, a, y ); //mirror arriba
line(x+width/2, b, a, height-y );
line(width/2-x, b, a, height-y ); //mirror abajo
}
void serialEvent(Serial port) {
// Data from the Serial port is read in serialEvent() using the read() function and assigned to the global variable: val
val = port.read();
// For debugging
// println( "Raw Input:" + val);
}