Recitation 9: Media controller

The project consisted in changing either a video or image, that could be altered in any way from the arduino. The project taught me to better understand the way in which we can affect images with a physical object.

I had some problems with the coloring due to a arduino problem, which i realized later on. Also I tried to give the value of the arduino an x value to multiply it as it went, but failed.

import processing.serial.*;

Serial myPort;
int valueFromArduino;
PImage photo;
int x=valueFromArduino;

void setup() {
size(1200, 650);

background(0);
photo= loadImage(“beagle.jpg”);
printArray(Serial.list());
// this prints out the list of all available serial ports on your computer.

myPort = new Serial(this, Serial.list()[ 0 ], 9600);
// WARNING!
// You will definitely get an error here.
// Change the PORT_INDEX to 0 and try running it again.
// And then, check the list of the ports,
// find the port “/dev/cu.usbmodem—-” or “/dev/tty.usbmodem—-”
// and replace PORT_INDEX above with the index number of the port.
}

void draw() {
// to read the value from the Arduino
while ( myPort.available() > 0) {
valueFromArduino = myPort.read();
//image(photo, 0, 0);
//tint(x*5,x+300,2*x,100);
image(photo, 0, 0);
if ( valueFromArduino<100) {

tint(0, 0, 255);
// image(photo, 0, 0);
} else if ( valueFromArduino<200) {
tint(0, 255, 0);
// image(photo, 0, 0);
} else {
tint(255, 0, 0);
// image(photo, 0, 0);
}
}
println(valueFromArduino);//This prints out the values from Arduino
}

Leave a Reply