Task: Create a Media Controller
Arduino
Troubleshooting:
Processing
import processing.serial.*;
import osteele.processing.SerialRecord.*;
Serial serialPort;
SerialRecord serialRecord;
void setup() {
size(600, 600);
String serialPortName = SerialUtils.findArduinoPort();
serialPort = new Serial(this, serialPortName, 9600);
serialRecord = new SerialRecord(this, serialPort, 1);
}
void draw() {
background(255);
serialRecord.read();
int value = serialRecord.get();
float in= map(value, 0, width, 0, 1023);
float move = in;
fill(0);
beginShape();
vertex(300, 100);
// try adding/subtracting move for various parameters
bezierVertex(241, 104, 241, 104, 200, 140);
bezierVertex(100 + move, 300, 100 + move, 300, 300, 500);
bezierVertex(500 – move, 300, 500 – move, 300, 400, 140);
bezierVertex(359, 104, 359, 104, 300, 100);
endShape(CLOSE);
}
Everything was working great so now it was time to put in some video and images into processing!
Final code
import processing.serial.*;
import osteele.processing.SerialRecord.*;
Serial serialPort;
SerialRecord serialRecord;
import processing.video.*;
Movie myMovie;
void setup() {
size(600, 600);
String serialPortName = SerialUtils.findArduinoPort();
serialPort = new Serial(this, serialPortName, 9600);
serialRecord = new SerialRecord(this, serialPort, 1);
background(0);
size(512, 288);
myMovie = new Movie(this, “jing’an.mp4”);
myMovie.loop();
}
void movieEvent(Movie movie) {
myMovie.read();
}
void draw() {
image(myMovie, 0, 0);
serialRecord.read();
int value = serialRecord.get();
float newSpeed = map(value, 0, width, 0.1, 5);
myMovie.speed(newSpeed);
}
Final Product
Reflection
Overall, I think that my ideas and my creativity for this recitation was lacking. We’ve used the serial monitor from the potentiometer very frequently and I think it would’ve been more beneficial for me to try something new with perhaps a different sensor or switch. I also never really figured out the rotation of the video but I thought it looked very artistic as it was (like I felt like it was the kind of video that you would find projected at a museum). I want to experiment more with the video tool in processing since I think that it has potential for something more creative and unique than just a simple potentiometer imputing serial values.
Leave a Reply