Essay-clover

My final project name is Cooperate! Partner! The problem my project want to address is the group work problem especially the two person group which is common when doing the IMA project. I noticed this problem from my personal experience. When I doing my first IMA project, I almost do it individually even I am in a two person group. Every time when I work in the studio, I am alone and have to deal with all the difficulties by myself. This increase my workload and also gave me great mental pressure that I nearly broke down. Then latter, when doing my research I interviewed some of my friends who are all two person group working on a project. Surprising to me that most of them had really bad experience when doing the group work. Person1 told me that she cried many times because her partner doing nothing and put all the work on her. She is busy with her work and she is under great pressure. Person2 told me that he always argues with his partner because his partner sticks to his own idea and never listen to him. He found some shortages of his partners idea and try to improve the idea but his partner always ignores his suggestions. Person3 told me that although her partner cooperates with her to finish the project but she hope her partner can devote more time to their project to make it better. She said although her partner participates but she thinks her partner doesn’t spent as much time and effort as she did on the project. These are three mostly happen situations I gathered from my research when unhappiness happens during group work. This inspires me to design a project to improve the group work experience. I hope by doing this can make partners cooperate better and prevent the situation that people emotionally break down when doing the project. After the presentation, after hearing others suggestions and ideas, I think I can make my audience broader to improve the cooperation between people who may not be familiar with each other. I hope for those who don’t know each other, after playing this game, they can get to know each other by doing the physical interaction cooperating with each other and this is also the significance of my project. Also, I hope the project can really improve the bad condition existing among the two person team.

For the two projects inspire me one is the Little Nightmare. This let me think of using sound interaction to make people feel happier when they finish the work which also let they realize team work is valuable and meaningful. For the Pluck it, I let me think that to make the concept stronger, I may set different level to help strengthen the user experiencing the importance of cooperation to better convey my idea. 

I plan to use the cube to represent the project. By separating the cube into two part, the team work divided into two part. I plan to put the two part on the screen using processing so the users can see the changing of the two cube when they rotate their palm. Their visual feeling is directly linked with their physical feeling. They have to find the right angle of the piece to form the cube. This also represents they have a control of their work. By controlling the angle, I hope people feel that you need to participate in the group work and devote your effort. If you don’t adjust the right angle of the piece, your partner have to spend more time and effort to change her angle to adjust to you. Then comes to the cooperate part. At first, I plan to use the key to control the position of the piece. Then when I read the article The Future of Design: When you come to a fork in the road, take it, I was really inspired by the sentence “It is action-oriented, learning by doing, through repeated iterations of making, testing, and observation.” Then I notice that using the key on the keyboard lack the continuous interaction between two players, then I change to use the distance sensors to do this part. This also meet my definition for interaction which is having a back and forth communication with thoughts and physical input from both sides. The distance sensor will sense the distance, if two people getting closer, the piece will be closer. Also, they can standing up and squatting down to move the piece up and down. I have two plan, one is to put the sensor in a helmet wearing on the head another is to put it on the leg to let the user move their legs to change the position of the piece. This add the physical interaction connecting to the processing. Then when the two piece get together, I plan to put a delightful music to let the players be more satisfied with the success and considered cooperation a great and valuable action.

I plan to borrow the accelerometer and learn how it works and how to do the coding of the accelerometer on Nov.22. Then on Nov.24, I plan to build the processing image on the screen. On Nov.26, I plan to set the distance sensor connecting to the processing. Then on Nov.27, I plan to do the prototype to test whether the helmet is better to put the sensors on the leg is better. After doing this, I plan to add different levels for my project to make it more cooperative which also meet the goal that I hope people can better cooperate with each other after they play this game. I may also keep changing just like the article Introduction to Physical Computing suggesting “A lot of solutions will appear in your peripheral vision”, I will keep improving to make the interaction stronger.

Cited:

1.“The Future of Design: When You Come to a Fork in the Road, Take It.” Jnd.org, 23Apr.2016, https://jnd.org/the_future_of_design_when_you_come_to_a_fork_in_the_road_take_it/.

2.Introduction to Physical Computing. by O’Sullivan and Igoe.

Final Project Process: Essay by Ian (You Xu)

Project Title: Our Planet

PROJECT STATEMENT OF PURPOSE

The insight of this project comes after the discussion with Vivien Hao about our research and our focuses on the definition of “interaction.” Vivien researches a project named bomb that addresses energy safety issues. It aims at revealing the truth of reality and arouse the public’s awareness. Therefore, we believe “impact” is very important for a project of interaction to be meaningful and significant. Then, we together visited the website of the United Nations and researched “Sustainable Development Goals” to find some insight for us to address a social issue. We notice that the description of “GOAL 13: CLIMATE ACTION” says that “Climate change is a global challenge that affects everyone, everywhere” (United Nations). However, apparently, not everyone is familiar and aware of the happening climate change. Therefore, we want to build something interactive that addresses this issue. Since it has to be an interactive project, according to my previous research about the less successful project in PSA and successful project in teamLab Borderless Shanghai where everything is creative and collaborate, I believe that an open communication environment that engages the audience to have continuous participation is necessary. We soon recalled a smartphone app “Forest.” In this app, when staying away from your phone for a certain amount of time, the user will grow up a virtual tree on the phone. We, therefore, think that the image of tree growth is straightforward and friendly to the audience to show its indication of the environment. By paying effort to plant the tree and save the planet, use is getting constant feedback and engagement to reinforce their behaviors. It may even have a further impact on their real daily lives. Besides, we also visited the NASA website (https://climate.nasa.gov/) to look for some climate change facts as a reference to make sure it is scientifically reasonable. In all, this project addresses the general public’s awareness of the urgent climate change problem around the globe. It intends to encourage uses to minimize the carbon emission and pay effort to make a greener planet.

PROJECT PLAN

       The project will have a projection screen on the middle, four positions with shovels, and masks. When the user puts on the mask, once breathe, it consumes oxygen and produces carbon dioxide. When planting the tree, vice versa, and the tree grows larger. The planet will boom if it lacks oxygen and filled with carbon dioxide. The sketch of it is as follows.

sketch_final

Since our audience is the general public, they could be anyone. Therefore, we will have user testing among ourselves and our friends throughout the process of project development to empathize with them. We have some specific plans as follows.

  1. We need to be sure about the detail of the design by prototyping and test it with the users. The user test should be in every step. The details include: whether or not to include a mask in our project, what types of sensors we decide to use, what material we will use, how will the user interface look like; sound, start and end, layout, and position. We will test with the comfortability and the cleanness of the mask. We will finish the discussion for all the details and have a blueprint by Sunday, Nov. 24.
  2. We need to build the circuit and the program that are both scientific and humanized. This will be practical work. We may encounter many problems. We will refer to online references and asking for help. Once when we finish the user interface, we will have someone to test playing with it to make sure it makes sense to the audience about the expression of our initial design. Finish before Dec. 1.
  3. We need to get the materials and build up the basic functional prototype. This is practical work, as well. We only need to make sure it can support our project to work. It can be done by Dec. 1, as well.
  4. We need to test with the accuracy of counting the movement of the shovel and breathe. Also bug fixing work. This process needs constant revising and test among ourselves and our users. We will list out all the bugs the project has and fix them one by one until it works exactly what it is supposed to be. It should be done by Dec. 6.
  5. Beatifying the project and adding something to improve user experience and accessibility. This step we will need to decorate everything, make the wires invisible, test the projection. After we think it works, we will invite many groups of people to interact with it. By hearing their feedback, we can make some little changes to make it more user-friendly and accessible for as many people as possible. It should be done by Dec. 8.

CONTEXT AND SIGNIFICANCE

I researched the project of teamLab. It connects every human and non-human factor together. Therefore, I believe it builds a reciprocal communication and relationship between human and human, human and environment, environment and environment. Moreover, it inspires and impacts the user continually so that communication is everlasting and inclusive to them. The keyword – communication – in my reshaped definition of “interaction” hints me to design something that is encouraging and inspiring to the audience. I hope to build an immersive user interface to engage their communication while getting constant feedback. The movement of the shovel and the changing scene on the screen fulfills this requirement. Users will start to try shovel harder to reach the goal in the authentic settings that are relative to them. I also researched an assistive technology Marco Cart. As I described before, this project is functioning as a tool that addresses the real need and has an impact on society. Also, cooperating with Vivien’s research and understanding about “interaction,” we think a significant impact is also a considerable surplus to the significance of an interactive project. Combing “communication” and “social impact” together, this project uniquely brings a significant social issue into the reciprocal personal conversation with the general public in an interactive way. Even though the form of our project may look similar to some commercial smartphone apps like “Forest” and “AntForest” in Alipay, the theory, logic, frame, design, outcome, purpose, and significance are different. We address more on impact and communication while they might be designed to trick consumers for more economic profits. Our project may have further implications on a personal level. It may bring more people’s attention to the issue of climate change. In this way, some social movement projects and activities about environment protection may be more meaningful and more influential to the general public. By cooperation together, every single person has the power to devote a remarkable effort to make our planet greener and to make our livings more sustainable.

Final Project Essay – Zhao Yang

Project Title

Aircraft War

Project Statement of Purpose

Basically, we want to make an entertaining game for the final project. This game would be an aircraft game, in which the primary mechanics is that the player can control an aircraft to attack the enemy aircraft. This is a video that we found when we did the research and it is about a normal aircraft game. 

https://www.youtube.com/watch?v=XLAIqHptY_g

However, since there are already some aircraft games like this existing, we are trying to add some improvement to this kind of game to make it more meaningful and interesting. The game would have two modes. One mode is the infinite mode, in which the player needs to control the aircraft and tries to stay alive as long as possible. And the score depends on how many enemy aircraft he crashes and how long he could stay alive. In this sense, this mode mainly focuses on the entertaining role of the game. The user can play this mode to just relax to pass the boring time. The other mode is a story mode. In this mode, the basic way of interaction is the same as the infinite mode. But different from the infinite mode, the player not only can have fun by attacking the enemies but also can enjoy the story that we provide. Thus, as for the story mode, it can reveal some important meanings that we want to tell the users. In other words, the game itself is like a media for us to tell a meaningful story to the users. Moreover, the difficulty of the story mode is actually decreasing instead of being harder and harder, which could give the user a sense of success because he can be stronger after passing a level. All in all, this game can not only provide the user with an entertaining role but also tell the user a meaningful way so that they can enjoy the game itself as well as the story. And the users can play this game to pass the boring time, and if they play the story mode, they can also relax by experiencing a meaningful and interesting story. 

Project Plan

For the first step, I think we can come up with a story that can be told vividly by this game. A suitable story is really important for our project because if the story is nor suitable for the game, the players cannot fully engage in the atmosphere that we want to create. Besides, a good story can not only resonate with the player but also can attract the user to continuously play the game. After creating the story, the next step is to consider how to express the story by this game. For example, what kind of background music we can use to reinforce the emotion of the story? How to show the story visually to the user? Using video, or images, or playing the game with the sound of telling the story? We need to hold up these questions and ask ourselves when we make the game. Since we just learned how to interact with videos and images by Processing, it brought me many ideas about expressing the story that I can apply to our project. The third step is to think about how the users can interact with the game. In other words, it’s to think about the structure of the game. I think we would do this step through two aspects. One is to consider the user experience. According to Igoe and O’sullivan’s text, there is a figure about how the computer sees humans. This figure only contains three parts, which are a finger, two ears, and one eye. This figure implies how people usually interact with computers. In my opinion, if we can only use fingers to interact with a project, it would be too limited and boring. Thus, the user experience is really significant for a successful interactive project. And this is also what we need to consider for our final project. According to our thoughts now, we want to simulate the experience of driving a plane as a part of user experience. The other aspect is the game itself. As there are already a lot of similar aircraft games existing, if we just copy one without any innovation, our project would be meaningless. Hence, we need to make some changes to make this game more interesting and meaningful. For example, the story mode is one of the innovations we have on this project. The fourth step is to try to make the game by Processing and complete the user experience by Arduino. After having a prototype of the game, we can have some user tests and gain some feedback to make our game better. And this is probably our last step. 

Context and Significance

As I mentioned above, the user experience should not be limited by finger, eyes, and ears. My preparatory research also inspires me a lot. 

https://circuitdigest.com/microcontroller-projects/virtual-reality-using-arduino

This project requires the user to wear a glove made by Arduino. And the user can interact with the Processing via the glove and the output totally depends on the movement of his hand and arm. It breaks the limitation of fingers. Thus, I also came up with some ideas that users can use their feet and a joystick to control the plane. I think it can give them a sense that they are actually sitting in an aircraft and control it. Also, the way of simulating the real driving experience can attract the user to continuously play this game and can make people engage in the plot of the story. Therefore, it aligns with my definition of interaction that interaction is a cyclic process. If we can successfully make it, it would be a special aircraft game. By the way, we are actually recreating an existing game. The interactive parts of the common aircraft games are mostly using the keyboard or a mouse to control the aircraft. So the way of interaction is our first innovation. Moreover, the story mode is another innovation. In this way, the users can enjoy the feeling of killing enemies as well as the experience of listening to an interesting story. And the users can also play the infinite mode to try to get a high score and compete with other players. 

Essay of final project

Bouncing Ball Adventure

  • Project Statement

At first, I couldn’t figure out how to combine Arduino and Processing to make an interaction since if the Arduino is connected to the computer, then many characteristics like mobility will lose. Moreover, I think lots of interactions Arduino and Processing are the same and I don’t want to create something just to combine these two tools.

Then I considered the differences between the interaction that Arduino and Processing provided. Then I realize that Arduino can provide more physical interaction than the processing does, and processing can provide more visual interaction than Arduino does. For instance, on one hand, in Processing, the only physical interactions it can provide are just key pressed and mouse click, which is very boring and provide an unreal interaction compared to what Arduino provided. Also, Processing lack sensors to feel the environment. On the other hand, in Arduino, it can provide thousands of different sensors to feel the environment and make the interaction more interesting using different components. Nevertheless,Arduino can’t provide things like images and animations that can give the audience visual shock. (The very famous project “wooden mirror”(https://www.youtube.com/watch?v=Wb6eFGbwPeA))  Restricted by the reality physics rule, it can’t make things like a ball which can keep bouncing forever. However, the game with reality is more likely to be more interesting than the none-reality one. So, my idea comes here: to let the player play in reality, while they see their movement in the screen, and this is an interaction that forms a loop. This fits in the concept that I came up with in my last research. 

There are two differences after I heard the reflection from Rudi and other classmates.  The first difference is that I have changed the way to control this game. At the last time, I planned to used your hand to move in an area to control the block. However, I received some feedbacks of that this way is boring. I also received that it can be related to sports. So I rearranged the position of the distance sensor to detect the head instead of the moving hand to make sure the movement is bigger. The second difference is that I planned to set some barriers in the background and when the ball reach the barrier, the game lose. This set an uncertain factor in this game. 

game

The proposal is a game and the inspiration comes from the traditional bouncing ball example. I planned to divide the window into two parts: the left part is red, and the right part is blue and there is one ball of a different color bouncing in the space. There will be a block moving on the bottom of the window. Whoever managed to make the ball go to the other side will win. According to the reflection, I will also add some barriers like the black hole into the game

Here comes an interesting problem: how can we control the block? I planned to use a distance sensor to help you control the block. I will set an area where you can put the body in and the location of the block is decided by your position in the area. I think it will be an interesting game with a sports element and it is more practical to use.

2.1 Project Plan Step1 Processing

As stated above, the project is designed for two players to compete with each other, so the first step is to design a game for one player. The first thing to do in this step is to make the ball bounce in the space and make sure when the ball reaches a certain position, the ball will disappear and looks like it has bounced in a new space. In this part, I can use the code from our class about bouncing ball. The second thing I need to do is to make a moveable board that can rotate and when the ball touches the board. I haven’t come up with how can I make the code, but I think I can do it with the help of IMA fellows.

2.2 Project Plan Step2 Arduino

Compared to the code problem in Processing, the issue in Arduino seems easier to solve. What I need is just to use my experience during the mid-term and use a distance sensor to upload the data to Processing. Since my project is A to P, so the code in the Arduino Part is easier. To give the player response on that he/she has on the area, I plan to install a Green LED. When the distance sensor’s value is not the distance to the other side, the LED will be lightened up.

2.3 Project Plan Step3 Combined effort

This part is to combine Arduino and Processing, and moreover, double the work. The previous work is all about one-player issue, then in this step, I will consider the two-player game, which means I need to reduplicate the work if the previous steps doesn’t go wrong…

3.

First, my idea comes from traditional bouncing ball games but different from them in terms of the way of operating(the game is different, too!) And I was also inspired by the recent popular Nintendo’s Game: “Ring Fit Adventure”. This game used a ring to make the player interact and rank different games. I also want to make a similar game that combines computer world and reality.

ring fit adventure

Second, I also thought about the user interface. Since the other side and the ball are painted the same color and there is a hole in the “wall” of the two sides, it would be easy to know what the goal of the game is without much description. The idea of User Interface is in line with what I researched in the preparation for “Drone Collision Avoid System”(https://www.youtube.com/watch?v=L3l-zJafOncNo.4).

The meaning of my game is “achieving perfection”. The game wasn’t designed perfect when you play it, and the final goal of the game is to achieve perfection. This is the meaning I injected into the game. I also mentioned it in my group preparation.  

Recitation 8: Serial Communication Documentation by Ryan

Exercise 1: Make a Processing Etch A Sketch

For the interaction for two steps in this exercise, both of these steps are using potentiometers to interact, the interaction given by us is just switching the knob. But the interaction given by the processing is different, the first one is simple which is just the ellipse changing its size, the second one is more interactive as I am drawing a line on the screen and it can go wherever I want in the window. Also I customize its color based on its position in the window so that I can draw a gradient line which is more interesting and more interactive. The codes are as follow.

Processing code

// IMA NYU Shanghai
// Interaction Lab
// For receiving multiple values from Arduino to Processing

/*
* Based on the readStringUntil() example by Tom Igoe
* https://processing.org/reference/libraries/serial/Serial_readStringUntil_.html
*/

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 **/
int[] preValues;

void setup() {
size(500, 500);
background(0);
setupSerial();
preValues = new int[2];
}

void draw() {
updateSerial();
printArray(sensorValues);
println("cr");
printArray(preValues);
println("pre");
//fill(sensorValues[0],sensorValues[1],sensorValues[2]);
//rect(100,100,300,300);
background(0);
//ellipse(sensorValues[0],sensorValues[1],100,100);
strokeWeight(1);
stroke(sensorValues[0],sensorValues[1],preValues[0]);
line(sensorValues[0],sensorValues[1],preValues[0],preValues[1]);

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

// add your code

//
}

void setupSerial() {
printArray(Serial.list());
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.

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

Arduino code

// IMA NYU Shanghai
// Interaction Lab
// For sending multiple values from Arduino to Processing

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,500);
sensor2 = map(sensor2,0,1023,0,500);
// 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(",");
// 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(200);
}

Exercise 2: Make a musical instrument with Arduino

For this exercise, we can make interaction with a buzzer according to our key-press or mouse-move. It gives more ways of interaction compared to using knobs that you can only switch it and is comparatively not interactive. I can modify the keys to become a tone player that each key has a corresponding sound frequency and when pressing the keys on the keyboard in random sequence will turn out different melodies. And I can even change the frequencies to make different kinds of tones. So I think it is playful and highly interactive. The codes are as follow.

Processing code

// IMA NYU Shanghai
// Interaction Lab

/**
* This example is to send multiple values from Processing to Arduino.
* You can find the arduino example file in the same folder which works with this Processing file.
* Please note that the echoSerialData function asks Arduino to send the data saved in the values array
* to check if it is receiving the correct bytes.
**/

import processing.serial.*;

int NUM_OF_VALUES = 3; /** 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];

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

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

// changes the values
if(keyPressed){
if(key=='a'){
values[0] = 1;
values[1] = 1000;
}
if(key=='s'||key=='S'){
values[0] = 1;
values[1] = 1100;
}
if(key=='d'||key=='D'){
values[0] = 1;
values[1] = 1200;
}
if(key=='f'||key=='F'){
values[0] = 1;
values[1] = 1300;
}
if(key=='g'||key=='G'){
values[0] = 1;
values[1] = 1400;
}
if(key=='h'||key=='H'){
values[0] = 1;
values[1] = 1500;
}
}else{
values[0] = 0;
}
//for (int i=0; i<values.length; i++) {
// values[i] = i; /** Feel free to change this!! **/
//}

// sends the values to Arduino.
sendSerialData();

// This causess the communication to become slow and unstable1.
// 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 );
}

Arduino code

#define NUM_OF_VALUES 3 /** 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(13, OUTPUT);
pinMode(9, OUTPUT);
}

void loop() {
getSerialData();

// add your code here
// use elements in the values array
// values[0]
// values[1]
if (values[0] == 1) {
// digitalWrite(13, HIGH);
// } else {
// digitalWrite(13, LOW);
// }

// if (values[1] == 1) {
tone(9, values[1]);
// } else {
// noTone(9);
// }
}
if(values[0] == 0){
noTone(9);
}

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