Recitation 9 : Media Controller – Lillie Yao

Recitation Exercise:

For this recitation exercise, we were asked to display and image or use the webcam/camera and then use Processing and Arduino to manipulate the image with a physical controller.

I chose to use an image of my dog and then use Processing to manipulate the image so that when I turn the potentiometer, the image would change different tints according to the potentiometer value.

This recitation was fairly easy for me except I didn’t know that the image needed to be within the folder of my code in order for it to work. I also had some trouble with the if, then, else statements because I thought that was the only way I could control the tint changing. I figured out that I just need to use sensorValues and map the function and then the potentiometer would do the rest. I also found out that the code needed to be in a certain order for it to work, instead of having tint be the last function, I had it first and my code wouldn’t work.

Arduino Code:

void setup() {
Serial.begin(9600);
}

void loop() {
int sensorValue = analogRead(A0);
Serial.print(sensorValue);
Serial.println();

// int mapValue = (sensorValue, 0, 1023, 0, 255);
// Serial.write(mapValue);

// too fast communication might cause some latency in Processing
// this delay resolves the issue.
delay(10);
}

Processing Code:

PImage img1;
import processing.serial.*;

Serial myPort;
String myString = null;

int valueFromArduino;
int[] sensorValues = new int[1];

void setup() {
size(500, 500);
//background(0);
img1 = loadImage(“sparkie.jpeg”);
setupSerial();
}

void draw() {
// to read the value from the Arduino
updateSerial();
printArray(sensorValues);
image(img1,0,0);
float x = map(sensorValues[0], 0, 1023, 0, 255);
tint(x,200,200);
}

void setupSerial() {
printArray(Serial.list());
myPort = new Serial(this, Serial.list()[2], 9600);

myPort.clear();
// Throw out the first reading,
// in case we started reading in the middle of a string from the sender.
myString = myPort.readStringUntil( 10 ); // 10 = ‘\n’ Linefeed in ASCII
myString = null;

sensorValues = new int[1];
}

void updateSerial() {
while (myPort.available() > 0) {
myString = myPort.readStringUntil( 10 ); // 10 = ‘\n’ Linefeed in ASCII
if (myString != null) {
String[] serialInArray = split(trim(myString), “,”);
if (serialInArray.length == 1) {
for (int i=0; i<serialInArray.length; i++) {
sensorValues[i] = int(serialInArray[i]);
}
}
}
}
}

Video Documentation:

Reflection:

In this recitation, the use of technology was very prominent. I didn’t use technology as much as the people who decided to make their image a web cam instead, but I still made use of it. Without technology, I wouldn’t have been able to get images onto my computer and into Arduino and Processing. Technology plays a big role considering the fact that basically everything I did involved my computer: Arduino being connected to the USB port, images stored on the computer, Processing software on the computer. I found this also very similar to Rafael Lozano-Hemmer’s installation of Standards and Double Standards (2004). Where the project is basically functioning only because of the technology controlling it. Pretty much all interactive art revolves around technology, but I was specifically drawn to this piece because it was very abstract and different from anything I’ve ever seen

Leave a Reply