Final Project–The epic of us–Ketong Chen–Inmi

  For this final project, I teamed with Tya to build our project”The epic of us”. I learned a lot during the process of making the project and I want to thank my professor and my best partner Tya and all assistants who give me a lot of help.

CONCEPTION AND DESIGN:

  Since our project is a board game that involves two players to role-play the leader of two civilizations, we want them to try to attack each other for their development of the country. We first thought about using the fsr sensor to create a device to let the user to hit and the force the user put on will determine the damage of the other civilization. To use the fsr sensor, we need to figure out how to store the maximum value that the fsr senses during a certain period of time. But later we find it hard to control the sensor(the same problem we have met during the midterm project). And we also had two buttons for the players to begin the game, so we decide to use the button to do all interactions, the times the button be pressed would decide the damage degree. And to make the game more engaging, we put 48 LEDs on our board which nearly drove us crazy. We first try to use a chip called 74HC595 to control 8 LEDs with 3 pins from the Arduino(since we need 48LEDs and there are not enough pins), but after several days of struggling, it did not work. Though really discouraged, we still want LEDs on our board to show the steps of the players. Finally, we use Arduino Mega which has 54 pins in total to connect LEDs and Adruino. When connecting the LEDs, the Mega did not work for some reason, after asking the fellow, I learned that I should not connect the pin 0 and pin 1 to LEDs since they are used for Mega to talk with the computer. Also, the LEDs are not stable and the wires always fall off so we need to frequently check them and fix them. And about the materials of the board, we first used cupboard but we were not satisfied with it because it was a little bit soft and did not delicate enough. We used wood at last and to make the board larger, we used two wood boards and stuck them together.

FABRICATION AND PRODUCTION:

  We laser cut many pictures on our board to decorate and show the process of the development of human societies. It is a very annoying job to turn all the pictures into the forms that the machine can recognize. I asked the fellow for help and the link here is very useful. But due to the different versions of the illustrator and photoshop, I first had difficulties delete the white color in the pictures. But later I figured it out. During the user testing, because we failed to figure put the use of the HC74595 chip so we did not use LEDs to show the steps of the players, we had to use two real characters and let the users to move the characters by themselves. Then the problems came out that the game board is separate from the computer screen so when users moved their characters they had to turn away to looked the board which caused them to miss some instructions on the screen. So we were determined to add the LEDs and combined the screen and the board together to create a better game. So we later laser cut a bigger board with holes on it to out LEDs. And also during the process of watching the users play the game, we found that the speed of changing the instructions is too high for someone who played the game for the first time so we later make some adjustments to make it more readable. 

CONCLUSIONS:

  According to my definition of interaction before —— a cyclic process that requires at least two objects (both animate and inanimate are accepted) individually has its input-analyze-output, and the whole process should be meaningful. Our project aims to let people be aware of a better way to develop is to collaborate rather than fight with each other. If people fight with each other for the resources they want they will go astray together. Since it is a board game it has a cyclic process and also meaning behind it which aligns with my definition of interaction. When people interact with our project, they did not hesitate to attack each other and they were surprised to see both of two civilizations be destroyed in the end. But later someone said that we did not give the player a clear instruction that they can choose not to attack. We want to let people choose from attack or not to attack, but it turned out that they did not have the intention to choose. That’s the point we need to further think of and improve. Usually, people will not do what you expect them to do and that’s why there is always room for improvement. If we have more time, we will make it clear for people that they have the choice to not to attack other civilizations. From my perspective, I am happy that we conveyed our idea to people. Hope our project has brought fun and deep thoughts. 

The picture for our project:

Recitation 10–Workshops–Ketong Chen

We have a workshop today and I chose to attend the serial communication because our final project needs Arduino to talk with processing to control the LED and the words in the processing.

We learn to use the map function and I use it to change the value of potentiometer from 0 to 1023 to 0 to 500 to keep the ellipse within the screen. And when the button is pressed, the size of the ellipse change.

Here is the video:

Here is the code:

void setup() {
Serial.begin(9600);
pinMode(9,INPUT);
}

void loop() {
int sensor1 = analogRead(A0);
int sensor2 = digitalRead(9);
//int sensor3 = analogRead(A2);

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

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

import processing.serial.*;

String myString = null;
Serial myPort;


int NUM_OF_VALUES = 2;   /** YOU MUST CHANGE THIS ACCORDING TO YOUR PROJECT **/
int[] sensorValues;      /** this array stores values from Arduino **/


void setup() {
  size(500, 500);
  background(0);
  setupSerial();
}


void draw() {
  updateSerial();
  printArray(sensorValues);

  // use the values like this!
  // sensorValues[0] 

  // add your code
background(0);
 
  float posX = map(sensorValues[0],0,1023,0,500);
  int size;
  if (sensorValues[1]== 0){
    size = 50;
  }else{
    size = 100;
  }
   ellipse(posX, 300,size,size);
  
  
}



void setupSerial() {
  printArray(Serial.list());
  myPort = new Serial(this, Serial.list()[ 3 ], 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.

  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[NUM_OF_VALUES];
}



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 == NUM_OF_VALUES) {
        for (int i=0; i<serialInArray.length; i++) {
          sensorValues[i] = int(serialInArray[i]);
        }
      }
    }
  }
}

Recitation 9–Media Controller–Ketong Chen

Processing

During the recitation, I used the potentiometer to control the speed of the video. Since I only need one value from the potentiometer, I use the one value sample code. During the process, I first have difficulty putting the video in my data folders, but later I found that I actually download the wrong format of the video. It should always be .mp4 or .mov. Here are the codes:

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

Serial myPort;
int valueFromArduino;


void setup() {
  size(240, 426);
  background(0);

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

  myPort = new Serial(this, Serial.list()[ 3 ], 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.


  myMovie = new Movie(this, "Lilly.mp4");
  myMovie.loop();
}
void movieEvent(Movie movie) {
  myMovie.read();  
}
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
  image(myMovie, 0, 0,240,426);   
  float newSpeed = map(valueFromArduino, 0, width, 0.1, 5);
  myMovie.speed(newSpeed);
}

Arduino

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

void loop() {
int sensorValue = analogRead(A0) / 4;
Serial.write(sensorValue);

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

video:

After reading the text Computer Vision for Artist and Designers 

I understand that the computer vision technology was once constrained in military and law enforcement purposes. But it can also be used by interactive media artists to build vision-based detection projects to benefit the society. I was amazed by the project Suicide Box by the Bureau of Inverse Technology (Natalie Jeremijenko and Kate Rich) mentioned in the reading. It is a motion­detection video system and track the vertical motion of the jumpers to record the data. It let me think about the moral problems and questions we created when we make a project and after we have created the project, what is the relation between the maker and the project as well as the people interact with it. The project should be meaningful which contains the thoughts of the artists or better to reveal or solve some real problems. I hope I can use processing and Arduino to make a meaningful final project.

The epic of us–Final Project Essay–Ketong Chen

 PROJECT STATEMENT OF PURPOSE

  The project aims to stress the importance of collaboration between countries which can bring benefits to all human beings. My partner and I are inspired by the brutal consequence caused by wars and fights between countries for resources and money and we want to make a game to aware people that the only way we humans can develop is to cooperate in peace. Violence will lead to nowhere but destroy.

  This is a game which involves two people. We are going to create a landscape(made by cupboard)which is divided into three areas with a road that goes through it. The three areas will each represent primitive society, feudal society, and modern society. Along the road, there will be dozens of LED lights to show the players’ position(my partner is considering to use cars with trail tracking sensors on it to go along the road as a substitute for LEDs because of the difficulty it causes to hook up all LEDs in one board, but it is still under discussion). Both of the players will start from primitive society and they are acting the leader of their own society. In the beginning, each of them will have the same blood stripe and the same amount of resources(shown in Processing). If they want to develop their society, they need more resources and there are two ways to gain resources. Two players take turns to throw dice on Processing to decide how many steps they are going to take. The LED lights will blink to show their position. After they take steps, they will obtain weapons and random amounts of resources to feed their society. After the player gets the weapon, he can choose to use it or not. There will be a blood bar in the processing screen and a button to control the fill of the bar to let the player decide how much blood he want the other player to drop. Also, with the power of the weapon increase, the range of the bar will increase to represent more damage than a weapon can cause. If the player chooses to use the weapon the blood stripe of the other player will decline and he will gain half of the other player’s resources(the resources bar is still under discussion). If he chooses not to use the weapon. both players can obtain a certain amount of resources. As the game going on, when each player enters a new society, the background of their character shown in Processing will change relatively(still under discussion). The weapon players get will be more and more powerful which represents how does the development of the technology increase the collapsing force of the weapon such as the atomic bomb. And when one of the players gets the atomic and chooses to use it, both of the two societies will be destroyed and nobody wins. Also, there will be videos show the scene of the boom blow up to warn people of the dangers of the weapon.  But if the player chooses not to use it, bot of them will win the game and get rewards(candies).

PROJECT PLAN

  We plan to first finish the programming in processing before December 1st (figuring the dice and find video and pictures and let them talk to processing)and finish the build of the whole landscape and the connection of the Arduino and let them talk to each other before December 5th.

CONTEXT AND SIGNIFICANCE

  According to my previous research, I have analyzed these project:

Ethical Things – The mundane, the insignificant and the ‘smart’ (things) 

https://www.creativeapplications.net/objects/ethical-things-the-mundane-the-insignificant-and-the-smart-things/

the Blanket Project by Nicholas Stedman from

 ART + Science NOW, Stephen Wilson (Kinetics chapter)

Smile TV – It works only when you smile 

https://www.creativeapplications.net/maxmsp/smile-tv-works-only-when-you-smile/

Click Canvas

https://www.creativeapplications.net/member-submissions/click-canvas/

These complete my definition of interaction: a cyclic process that requires at least two objects (both animate and inanimate are accepted) individually has its input-analyze-output. Also, the whole process needs to be meaningful and forms a loop that allows the user to continually interact with it. Our final project–the epic of us, target everyone in the earth to let them be aware of the severe consequence caused by the fights between countries for resources and profits. It is fun since it is a game, it can give a response to the player’s action and allow the player to take another action. Also, interaction appears between two players since they have to interact with each other to win,

   

Recitation 8 Serial Communication–Ketong Chen

 Exercise 1 Make a Processing Etch A Sketch

The first exercise was to make a processing Etch A Sketch. To make it, we need two potentiometers to each control the x values and the y values of the line. Also, we need to keep track of the previous x and y values to draw a line from there to the new x and y positions. Here is the sketch:

First, I use two potentiometers to control the position of the ellipse which is quite easy since we have covered it in class. Here is the video:

  Then I need to figure out how to draw a line and I have no idea at first. I know I have to keep track of the previous x and y values so I float prex and prey. And I make prex=sensorvalues[0] and prey=sensorvlues[1] to keep track of the previous values. So the line is: line(prex,prey,sensorvalues[0],sensorvalues[1]). And it worked, here are the video and code.

import processing.serial.*;

String myString = null;
Serial myPort;


int NUM_OF_VALUES = 2;   /** YOU MUST CHANGE THIS ACCORDING TO YOUR PROJECT **/
int[] sensorValues;      /** this array stores values from Arduino **/
float prex = 0;
float prey = 0;

void setup() {
  size(500, 500);
  background(255);
  setupSerial();
}


void draw() {
  updateSerial();
  printArray(sensorValues);
line(prex,prey,sensorValues[0],sensorValues[1]);
stroke(5);
prex=sensorValues[0];
prey=sensorValues[1];


  // use the values like this!
  // sensorValues[0] 

  // add your code

  //
}



void setupSerial() {
  printArray(Serial.list());
  myPort = new Serial(this, Serial.list()[ 3 ], 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.

  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[NUM_OF_VALUES];
}



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 == NUM_OF_VALUES) {
        for (int i=0; i<serialInArray.length; i++) {
          sensorValues[i] = int(serialInArray[i]);
        }
      }
    }
  }
}

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

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

// keep this format
Serial.print(sensor1);
Serial.print(“,”); // put comma between sensor values
Serial.print(sensor2);

Serial.println();

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

Exercise 2 Make a musical instrument with Arduino

I aim to make the buzzer change sound with the movement of my mouse and stop making sound when press the key. I used the if statement to control but it seem to have a delay between the press of the key and the stop of the sound. I also used the tone function.

Here are the sketch and video:

code:

import processing.serial.*;

int NUM_OF_VALUES = 10;  /** YOU MUST CHANGE THIS ACCORDING TO YOUR PROJECT **/


Serial myPort;
String myString;

// This is the array of values you might want to send to Arduino.
int values[] = new int[NUM_OF_VALUES];
int x;
int y;

void setup() {
  size(500, 500);
  background(0);

  printArray(Serial.list());
  myPort = new Serial(this, Serial.list()[ 3 ], 9600);
  // check the list of the ports,
  // find the port "/dev/cu.usbmodem----" or "/dev/tty.usbmodem----" 
  // and replace PORT_INDEX above with the index of the port

  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;
}


void draw() {
  background(0);
  x = mouseX;
  map(x,0,600,31,4000);
  y = mouseY;
  map(y,0,600,31,4000);
   

  // changes the values
  for (int i=0; i<values.length; i++) {
    values[0] = x;  /** Feel free to change this!! **/
    values[1] = y;
  }
if(keyPressed){
     values[2]=0;
   }
     else{values[2]=1;
   }
   ellipse(x,y,20,20);
     // sends the values to Arduino.
  sendSerialData();

  // This causess the communication to become slow and unstable.
  // You might want to comment this out when everything is ready.
  // The parameter 200 is the frequency of echoing. 
  // The higher this number, the slower the program will be
  // but the higher this number, the more stable it will be.
  echoSerialData(200);
}

void sendSerialData() {
  String data = "";
  for (int i=0; i<values.length; i++) {
    data += values[i];
    //if i is less than the index number of the last element in the values array
    if (i < values.length-1) {
      data += ","; // add splitter character "," between each values element
    } 
    //if it is the last element in the values array
    else {
      data += "n"; // add the end of data character "n"
    }
  }
  //write to Arduino
  myPort.write(data);
}


void echoSerialData(int frequency) {
  //write character 'e' at the given frequency
  //to request Arduino to send back the values array
  if (frameCount % frequency == 0) myPort.write('e');

  String incomingBytes = "";
  while (myPort.available() > 0) {
    //add on all the characters received from the Arduino to the incomingBytes string
    incomingBytes += char(myPort.read());
  }
  //print what Arduino sent back to Processing
  print( incomingBytes );
}

#define NUM_OF_VALUES 10 /** YOU MUST CHANGE THIS ACCORDING TO YOUR PROJECT **/

/** DO NOT REMOVE THESE **/
int tempValue = 0;
int valueIndex = 0;

/* This is the array of values storing the data from Processing. */
int values[NUM_OF_VALUES];

void setup() {
Serial.begin(9600);
pinMode(10,OUTPUT);
}

void loop() {
getSerialData();
if(values[2] == 1){
tone(10,values[1],1000/values[0]);
}else{
noTone(10);
}

// add your code here
// use elements in the values array
// values[0] // values[1] }

//recieve serial data from Processing
void getSerialData() {
if (Serial.available()) {
char c = Serial.read();
//switch – case checks the value of the variable in the switch function
//in this case, the char c, then runs one of the cases that fit the value of the variable
//for more information, visit the reference page: https://www.arduino.cc/en/Reference/SwitchCase
switch (c) {
//if the char c from Processing is a number between 0 and 9
case ‘0’…’9′:
//save the value of char c to tempValue
//but simultaneously rearrange the existing values saved in tempValue
//for the digits received through char c to remain coherent
//if this does not make sense and would like to know more, send an email to me!
tempValue = tempValue * 10 + c – ‘0’;
break;
//if the char c from Processing is a comma
//indicating that the following values of char c is for the next element in the values array
case ‘,’:
values[valueIndex] = tempValue;
//reset tempValue value
tempValue = 0;
//increment valuesIndex by 1
valueIndex++;
break;
//if the char c from Processing is character ‘n’
//which signals that it is the end of data
case ‘n’:
//save the tempValue
//this will b the last element in the values array
values[valueIndex] = tempValue;
//reset tempValue and valueIndex values
//to clear out the values array for the next round of readings from Processing
tempValue = 0;
valueIndex = 0;
break;
//if the char c from Processing is character ‘e’
//it is signalling for the Arduino to send Processing the elements saved in the values array
//this case is triggered and processed by the echoSerialData function in the Processing sketch
case ‘e’: // to echo
for (int i = 0; i < NUM_OF_VALUES; i++) {
Serial.print(values[i]);
if (i < NUM_OF_VALUES – 1) {
Serial.print(‘,’);
}
else {
Serial.println();
}
}
break;
}
}
}