Recitation 9 Media Controller

Recitation 9 Media Controller 

During this recitation I used a potentiometer connected to Arduino as the controller of the speed of a video file uploaded to processing. 

(Video used uploaded by Charles Icay )

For the Arduino code, I used the class example code for one variable from Arduino to processing. while the code for processing is as follows:

import processing.serial.*;
import processing.video.*;
Movie myMovie;

Serial myPort;
int valueFromArduino;

void setup() {
fullScreen();
// size(800,800);
background(0);
myMovie = new Movie(this, “dog.mp4”);
myMovie.loop();

printArray(Serial.list());
// this prints out the list of all available serial ports on your computer.

myPort = new Serial(this, Serial.list()[24], 9600);}

void movieEvent(Movie movie) {
myMovie.read(); }

void draw() {
while ( myPort.available() > 0) {
valueFromArduino = myPort.read(); }
println(valueFromArduino);//This prints out the values from Arduino

background (0);
image(myMovie, 0, 0);
float newSpeed = map(valueFromArduino, 0, 255, 0.1, 5);
myMovie.speed(newSpeed);}

The result was successful as I managed to make the video go faster and slower depending on the potentiometer values as show in the screen video below that was taken while I made the potentiometer values smaller and higher. 

As the reading Computer Vision for Artist and Designers,  explained “The intervening decades of research have yielded a great wealth of well­understood, low­level techniques that are able, under controlled circumstances, to extract meaningful information from a camera scene. These techniques are indeed elementary enough to be implemented by novice
programmers at the undergraduate or even high­school level.” which can be applied to today’s recitation, as just using a potentiometer, the computer vision can be modified as the user pleases. The ability for the user to change the computer vision as he pleases is the substance of interactivity as there is communication between the participant and the computer. 

Recitation 9: Media Controller by Amy DeCillis

Media Controller

Arduino Code

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

void loop() {
  int sensor1 = analogRead(A0);
  int sensor2 = analogRead(A1);
  int sensor3 = analogRead(A2);

//  sensor1 = map(sensor1,0,1023,0,100);
  sensor1 = map(sensor1,0,1023,0,255);
  sensor2 = map(sensor2,0,1023,0,255);
  sensor3 = map(sensor3,0,1023,0,255);

  // keep this format
  Serial.print(sensor1);
  Serial.print(",");  // put comma between sensor values
  Serial.print(sensor2);
  Serial.print(",");  // put comma between sensor values
  Serial.print(sensor3);
  Serial.println(); // add linefeed after last value

  delay(100);
}

Processing Code

import processing.serial.*;

String myString = null;
Serial myPort;

int NUM_OF_VALUES = 3;   
int[] sensorValues;      

PImage photo;
void setup() {
  size(1100, 700);
  background(0);
  setupSerial();
  photo = loadImage("door.jpg");
}

void draw() {
  updateSerial();
  printArray(sensorValues);
  imageMode(CENTER);
  image(photo, width/2, height/2);
  tint(sensorValues[0],sensorValues[1],sensorValues[2]);
}

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

  myPort.clear();

  myString = myPort.readStringUntil( 10 ); 
  myString = null;

  sensorValues = new int[NUM_OF_VALUES];
}

void updateSerial() {
  while (myPort.available() > 0) {
    myString = myPort.readStringUntil( 10 ); 
    if (myString != null) {
      String[] serialInArray = split(trim(myString), ",");
      if (serialInArray.length == NUM_OF_VALUES) {
        for (int i=0; i<serialInArray.length; i++) {
          sensorValues[i] = int(serialInArray[i]);
        }
      }
    }
  }
}

Reflection

Recitation 9: Media Controller by Ashley Zhu

In recitation today, we manipulated media and used Arduino as a controller to induce media output through processing. This exercise was simpler, after working with AtoP and PtoA using multiple values from last week’s recitation.

Steps

For my task, I used a potentiometer to control the translation and rotation feature of my sunset image that I took. After putting the image in a new folder in my big folder, I called on the image and then manipulated the pushMatrix and popMatrix functions to allow my image to rotate as I twisted my potentiometer for interactivity. I looked at a few of the example codes given to us in class earlier this week and adjusted the movie rotate code to fit into my image rotating code. I also put the relevant ledPin in the Arduino code for the two programs to connect.

Reading

After reading the article “Computer Visions for Artists and Designers” by Golan Levin, it made me reflect a lot about technology and the course of interaction lab as a whole, as we manipulate technology with media in the class. As computer programming develops, the ways people use it evolves as well. Whereas before, people mostly coded for hardware or software for websites, businesses or other mediums, today, coding can also be used to display art and media. One of the quotes in the article stood out to me, “many more software techniques exist, at every level of sophistication, for detecting, recognizing, and interacting with people and other objects of interest” (Levin). This is very interesting because the interaction between technology and art is possible through these developments in specific levels of detection and interaction that allows the audience to communicate with the subject. I was inspired by how this article displays many different art projects to present art in a new fashion, through technology. In my project, I was able to combine media with interaction using technology, which is both innovative and interesting not only to look at but also to create. I was also inspired by how I can use technology as a medium to communicate and interact with the audience in an amusing and modern way.

Video

Final Code: Arduino

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

void loop() {
int sensor1 = analogRead(A0);
int sensorValue = map(sensor1, 0, 1023, 0, 255);
Serial.write(sensorValue);

delay(10);
}

Final Code: Processing

// IMA NYU Shanghai
// Interaction Lab
// This code receives one value from Arduino to Processing 

import processing.serial.*;


Serial myPort;
int valueFromArduino;
PImage img1;
color mouseColor;
float mouseR, mouseG, mouseB;

void setup() {
  size(1086, 724);
  img1 = loadImage("SUNSET.jpeg");
  background(0);

  printArray(Serial.list());
  // this prints out the list of all available serial ports on your computer.

  myPort = new Serial(this, Serial.list()[13], 9600);
}


void draw() {
  // to read the value from the Arduino
  while ( myPort.available() > 0) {
    valueFromArduino = myPort.read();
  }
  println(valueFromArduino);//This prints out the values from Arduino
  
  pushMatrix();
  translate(100, 100);  
  rotate(radians(map(valueFromArduino, 0, height, 0, 500)));
  
  image(img1,100,100,width/(valueFromArduino+1),height/(valueFromArduino+1));
  
  
  popMatrix();
  
  mouseColor = img1.get(mouseX, mouseY);
  mouseR = red(mouseColor);
  mouseG = green(mouseColor);
  mouseB = blue(mouseColor);
  println(mouseR+" "+mouseG+" "+mouseB);
  set(width/2,height/2,mouseColor);
}

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
}

Final Project Essay – Sarah Chung

Our final research project is titled, The Better Reader. It aims to test concentration and focus as well as memory retention. Inspired by games and exercises that help with dyslexia, our project hopes to create a fun way for anyone to exercise their brain in an educational and interactive way. The Better Reader though inspired by exercises to help for dyslexia, hopes to appeal to a range of people as well.

From personal experience with family members suffering with Alzheimer’s, mental games allow for much needed mental exercise and is not only encouraged for those who suffer with the illness but also those who don’t. Brain and memory recall not only becomes more relevant as persons get older but to students as well. Long-term memory is something we as students need to utilize every day and The Better Reader hopes to exercise that skill to lead to better information retention. With technology allowing us information at the touch of a screen, these days it seems as though all you really need to remember are the passwords to your devices. With that in mind , our project hopes to bring to light that we need to take time to challenge ourselves to exercise not only our bodies but also our minds. This aligns with my idea of interaction as it is cyclic, it is like a conversation in which the two parties think, listen and speak , there is an input and output and processing of information in between (Crawford, 1).

We want to input a range of words into our game’s memory and have them appear onscreen. Each word will be highlighted and the computer will randomly stop on a word. The player will be shown all the words played and must remember which word the computer stopped on and select it. The further the players gets the faster the words will appear and will consequently be harder to remember. For this part of the project we will utilize the random function on Arduino as well as processing. Processing will be utilized to make the words appear on screen as well as to highlight them. Arduino will be utilized for the hardware of the project. It will handle the users input through the buttons and assess whether the inputted value by the user matches the correct answer and send the information to processing .

         We realized getting persons to interact with our project may be a challenge as mental exercise is just as attractive as doing physical exercise. To combat this we hope to make our project attractive to users by creating a “flashy” or interesting interface that draws persons in. This can be achieved by incorporating pictures, sound and other media in our processing. We also hope to make the physical appearance (buttons, casing etc.) attractive as well by getting buttons similar to that of a video game. We hope to start the coding for the project within the week and test it out using the buttons from the lab. After this we hope to move onto designing the physical aspect of the project by the end of next week into the following week and making appointments to laser cut the housing for the buttons as well as purchasing more attractive buttons.