Final Project

For my final project I wanted to use an ethernet shield, SD card, and Light sensor to create a server with pictures of the sun and moon at different times of the day. I wanted the images to be change based on the changing values of the light sensor. The images that were supposed to be displayed can be shown through a hologram pyramid and rendered into a visual similar to a hologram.  However, I came across multiple setbacks that prevented me from completely finishing the project. At first I was able to send sensor data to the server without any issues. It wasn’t until I tried to include the pictures that I ran into problems.  Initially I was using a MKR1000 to create the server, but they are incapable of storing any images on them. I then switched to an ethernet shield and attempted to use an sd card to store the images on. The SD card that I attempted to use was incompatible with the ethernet shield. Once I acquired the correct sd car I then ran into complications sending data to the server. In a few moments of luck the server would actually work, however the time it took for the server to open the different images was almost 15 to 20 minutes basically making the project ineffective. I discovered that Arduino was having trouble converting the Strings that were created into Chars.

 

Here is an image from when it was workingIMG_0644

 

Here is an image of the error that keep recieving

IMG_0041

 

 

 

 

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>


// size of buffer used to capture HTTP requests
#define REQ_BUF_SZ   20

// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(10, 208, 7, 37); // IP address, may need to change depending on network
EthernetServer server(80);  // create a server at port 80
File webFile;
char HTTP_req[REQ_BUF_SZ] = {0}; // buffered HTTP request stored as null terminated string
char req_index = 0;              // index into HTTP_req buffer



  



void setup()
{
    // disable Ethernet chip
    pinMode(10, OUTPUT);
    digitalWrite(10, HIGH);
    
    Serial.begin(9600);       // for debugging
    
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");
    
    Ethernet.begin(mac, ip);  // initialize Ethernet device
    server.begin();           // start to listen for clients
}

void loop()
{
    EthernetClient client = server.available();  // try to get client


int analogChannel=0;
int sensor1 = analogRead(analogChannel);
    
    
    if (client) {  // got client?
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                // buffer first part of HTTP request in HTTP_req array (string)
                // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)
                if (req_index < (REQ_BUF_SZ - 1)) {
                    HTTP_req[req_index] = c;          // save HTTP request character
                    req_index++;
                }
                // print HTTP request character to serial monitor
                Serial.print(c);
                // last line of client request is blank and ends with n
                // respond to client only after last line received
                if (c == 'n' && currentLineIsBlank) {
                    // open requested web page file
                    if (StrContains(HTTP_req, "GET / ")
                                 || StrContains(HTTP_req, "GET /index.htm")) {
                        client.println("HTTP/1.1 200 OK");
                        client.println("Content-Type: text/html");
                        client.println("Connnection: close");
                        client.println();
                        webFile = SD.open("index.htm");        // open web page file
                    }
                    
                    
                    
                    
                    
                    if (sensorReading >350 && sensorReading<=450){
            client.println(" GET / moon.jpg");
          
          webFile = SD.open("moon.jpg");
                        if (webFile) {
                            client.println("HTTP/1.1 200 OK");
                            client.println();
                        }
          
          





         
          if(sensorReading>600 && sensorReading<=750){
            client.println("GET /page2.htm"); 
client.println("HTTP/1.1 200 OK");
                        client.println("Content-Type: text/htm");
                        client.println("Connnection: close");
                        client.println();
                        webFile = SD.open("page2.htm");
          }
         
                    
                   
                    
                    }


                    
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read()); // send web page to client
                        }
                        webFile.close();
                    }
                    // reset buffer index and all buffer elements to 0
                    req_index = 0;
                    StrClear(HTTP_req, REQ_BUF_SZ);
                    break;
                }
                // every line of text received from the client ends with rn
                if (c == 'n' && currentLineIsBlank) {
                    // last character on line of received text
                    // starting new line with next character read
                  
                
                
                
                
                
                } 
                else if (c != 'r') {
                    // a text character was received from client
                    currentLineIsBlank = false;
                }
            } // end if (client.available())
        } // end while (client.connected())
        delay(1);      // give the web browser time to receive the data
        client.stop(); // close the connection
    } // end if (client)
}

// sets every element of str to 0 (clears array)
void StrClear(char *str, char length)
{
    for (int i = 0; i < length; i++) {
        str[i] = 0;
    }
}

// searches for the string sfind in the string str
// returns 1 if string found
// returns 0 if string not found
char StrContains(char *str, char *sfind)
{
    char found = 0;
    char index = 0;
    char len;

    len = strlen(str);
    
    if (strlen(sfind) > len) {
        return 0;
    }
    while (index < len) {
        if (str[index] == sfind[found]) {
            found++;
            if (strlen(sfind) == found) {
                return 1;
            }
        }
        else {
            found = 0;
        }
        index++;
    }

    return 0;
}

Project Inspiration

I found an artist named Daniel Rozin that I think makes really interesting art. He has a series of similar projects that all revolve around mirroring objects. I find it incredibly interesting that he also uses custom software to create his projects.

 

trashshadowmedium

In this project Rozin uses 500 different pieces of trash. He places a small hidden camera within the middle of the piece and uses a microcontroller to send information from the camera to his computer which then runs custom software to turn the motors attached to the pieces of trash. He meant the project to be a reflection of what we discard.

Week 11 MKR 1000

Group members: Mel & Tristan

In this week’s project we were given a wifi enabled microcontoller and told to use it to create a client connection to a website or web service such as temboo. We were then supposed to take that information and use it to change something.

At first our idea was to use a web service like Temboo to call the Twitter API and use it to send a tweet from our Arduino, but in order to successfully call an API you need to register as a developer and then create an application. In order to create an application you need to enter a phone number which neither of us had. So instead we found a way that you can use temboo to search khan academy for the exercises on their website. So instead of the twitter idea we decided to use this to create a search for khan academy exercises.

 

Here is a video of it working

IMG_0562

 

 

 

#include <SPI.h>
#include <WiFi101.h>
#include <WiFiSSLClient.h>
#include <TembooSSL.h>
#include "TembooAccount.h" // Contains Temboo account information

WiFiSSLClient client;


int calls = 1;   // Execution count, so this doesn't run forever
int maxCalls = 10;   // Maximum number of times the Choreo should be executed

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

  // For debugging, wait until the serial console is connected
  delay(4000);
  while (!Serial);

  int wifiStatus = WL_IDLE_STATUS;

  // Determine if the WiFi Shield is present
  Serial.print("nnShield:");
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("FAIL");

    // If there's no WiFi shield, stop here
    while (true);
  }

  Serial.println("OK");

  // Try to connect to the local WiFi network
  while (wifiStatus != WL_CONNECTED) {
    Serial.print("WiFi:");
    wifiStatus = WiFi.begin(WIFI_SSID, WPA_PASSWORD);

    if (wifiStatus == WL_CONNECTED) {
      Serial.println("OK");
    } else {
      Serial.println("FAIL");
    }
    delay(5000);
  }

  Serial.println("Setup complete.n");
}

void loop() {
  if (calls <= maxCalls) {
    Serial.println("Running GetExercise - Run #" + String(calls++));

    TembooChoreoSSL GetExerciseChoreo(client);

    // Invoke the Temboo client
    GetExerciseChoreo.begin();

    // Set Temboo account credentials
    GetExerciseChoreo.setAccountName(TEMBOO_ACCOUNT);
    GetExerciseChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
    GetExerciseChoreo.setAppKey(TEMBOO_APP_KEY);
    GetExerciseChoreo.setDeviceType(TEMBOO_DEVICE_TYPE);


    // Set Choreo inputs
    Serial.flush();
    Serial.println("Please enter the name of the exercise you want: ");
    while ( !Serial.available() ) {
      ;;
    }
    String ExerciseNameValue = Serial.readString();
    Serial.println(ExerciseNameValue);

    GetExerciseChoreo.addInput("ExerciseName", ExerciseNameValue);

    // Identify the Choreo to run
    GetExerciseChoreo.setChoreo("/Library/KhanAcademy/Exercises/GetExercise");

    // Run the Choreo; when results are available, print them to serial
    GetExerciseChoreo.run();

    while (GetExerciseChoreo.available()) {

        String s = GetExerciseChoreo.readString();
        String code = s.substring(11,14);
        Serial.println("Looking for exercise...");
        //Serial.println(s);
        
        if(code == "200") {Serial.println("Exercise " + ExerciseNameValue + " found!");}
        else if(code == "500") {Serial.println("Could not find " + ExerciseNameValue);}
        else {Serial.println("Unknown Error: " + code);}

//      
//      char c = GetExerciseChoreo.read();
//      Serial.print(c);
    }



    GetExerciseChoreo.close();
  }

  Serial.println("nWaiting...n");
  delay(45000); // wait 30 seconds between GetExercise calls
}

Arduino Ethernet Shield

Group Member: Angelica

This week we were tasked with creating a server from an Arduino ethernet shield and then change the page based on data that we collect from the outside world.  When attempting this project the main issue that we ran into was the page to actually change based on the readings of from the sensor. We then realized that we needed to rework our code and add body tags to our code that was responsible for changing the color of the background. Once we figured that out everything was fine.

 

Here is a video of it working

IMG_0543

 



 #include <SPI.h>
#include <Ethernet.h>
String HTTP_req;
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network
// create your own MAC address for ther DF Robot shields
// no two boards can have the same address
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xDE
};

// if your router does not assign an IP address automatically through DHCP
// you'll need to enter your own in a range that wil be identified in the
// network
IPAddress ip(192, 168, 1, 105);

// Initialize the Ethernet server library
// with the IP port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
  // Open serial communications :
  Serial.begin(9600);

  Serial.println("Starting Etherweb ..... ");
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip); // ethernet connection with your defined MAC address
  // and IP address
  server.begin(); // start the server
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP()); // print the address to double check
}


void loop() {
  // create an instance of the client class
  // this is needed for an incoming client
  EthernetClient client = server.available();

  if (client) { // if a client connects

    Serial.println("new client");

    // HTTP requests end with a blank line
    // we'll use this to know the request from the client has finished
    boolean currentLineIsBlank = true;

    while (client.connected()) { // while someone is connected to the server

      if (client.available()) { // if there are bytes from the client
        // these would be sent via a broweser, etc
        
        char c = client.read(); // read a byte sent from a client
       HTTP_req += c;
        Serial.write(c); // print it to the serial monitor
      
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == 'n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh:1"); // refresh the page every second
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>"); // you need to expicitly wriet out all html

          // read the value of the input pin
          int sensorReading = analogRead(A0);
          // print it to the page
          client.print("analog input A0 is ");
          client.print(sensorReading);
          client.println("<br />");
        client.println("<body style='background-color:#000000'</body>");
          // change the font size every time the page is refreshed
         client.print("<p style='font-size:</p");
        client.print(map(sensorReading, 0, 1023, 1, 144));
          if (sensorReading <=50 ) {
            client.println("<body style= 'background-color:#000000'</body>");
          }
          if (sensorReading >50 && sensorReading<=100){
            client.println(" <body stlye= 'background-color:#64635'</body>");
          }
         if (sensorReading >100 && sensorReading<=200){
          client.println("<body style= 'background-color:#C0BB5D'</body>");
          }
          if(sensorReading >200 && sensorReading <=350){
            client.println("<body stlye= 'background-color:#D3CC57'</body>");
            
          }
          if(sensorReading >350 && sensorReading<=500){
            client.println("<body syle= 'background-color:#D3CC57'</body>");
            
          }
          if(sensorReading >500 && sensorReading<=650){
            client.println(" <body style = 'background-color:#E5DD50'</body>");
            
          }
          if(sensorReading >650 && sensorReading<=800){
            client.println(" <body style= 'background-color:#F7E729 '</body>");
          }
          if(sensorReading >800 && sensorReading<=900){

            client.println("<body style= 'background-color:#F9E812' </body>");
            }
           if(sensorReading >900 && sensorReading<=950){
            client.println("<body style= 'background-color:#FCEB16  ' </body>");

          if(sensorReading>950 && sensorReading<=975){
            client.println("<body style='background-color:#FEEB00 '</body>"); 

          }
          if(sensorReading>975){
            client.println(" <body> <img src='https://img.memesuper.com/25b5e6d79b17b1045701158a963f7d64_logo-teletubbies-sun-meme-teletubbies-sun-memes_960-640.jpeg'style='width:800px;height=800px;'></body");
            
          client.println("</html>"); // close the tag width="104" height="142">
          }
          Serial.print(HTTP_req);
          HTTP_req = " ";
          break; // escape the statement
        }
        if (c == 'n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } else if (c != 'r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
  }}

Physical Networks (Mel Jones)

During this spring break I traveled to Wenzhou and a small neighboring city in the mountains called Yantou. Being that these two places were sort of tourist areas and relatively modern, each city did have some kind of physical network in use.

 

 

 

IMG_0039

One that I saw seemed liked some kind of radio or cell tower. It was the one of the only towers I noticed in Wenzhou.

 

IMG_0040

In Yantou they have a waterfall that serves as one of their main tourist attractions. Inside they actually had a surprising amount of security cameras throughout the attraction.

RFID Lab

Instructor: Scott

Partner: Olesya

 

In this weeks lab we were tasked with taking a unique RFID tag and using it to trigger another device or sketch in processing. At first my group ran into some difficulties as the Arduino sketches we were running were having difficulty recognizing the NFC scanner we connected. It turns out that the libraries that we tried to include in the sketch were not installed correctly. Once we sorted this out we were then able to successfully send data from Arduino to processing. Although we did figure out how to send the data to processing we decided to not create a sketch to control in processing. Instead we decided to write to the tag so that when we scan it with an android phone it causes the phone to automatically open a link on youtube.

 

 

 

 

 

Here is a video of the arduino sending data to processing

 

 

And here is a video of the tag being scanned by an android.

 

 

 

 

 

#include <PN532_HSU.h>
#include <PN532.h>
    
PN532_HSU pn532hsu(Serial1);
PN532 nfc(pn532hsu);

void setup(void) {
  Serial.begin(115200);
  

  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }
  
  // Got ok data, print it out!
//  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); 
//  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); 
//  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
//  
  // Set the max number of retry attempts to read from a card
  // This prevents us from waiting forever for a card, which is
  // the default behaviour of the PN532.
  nfc.setPassiveActivationRetries(0xFF);
  
  // configure board to read RFID tags
  nfc.SAMConfig();
    
  //Serial.println("Waiting for an ISO14443A card");
}

void loop(void) {
  boolean success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
  uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
  
  // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found
  // 'uid' will be populated with the UID, and uidLength will indicate
  // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
  
  if (success) {
//    Serial.println("Found a card!");
//    Serial.print("UID Length: ");
//    Serial.print(uidLength, DEC);
//    Serial.println(" bytes");
//    Serial.print("UID Value: ");
//    for (uint8_t i=0; i < uidLength; i++) 
//    {
     //Serial.print(" 0x");
      Serial.println(uid[0]); 
      
      
      
      
     
//
//    }
    
   // Serial.println("");
    // Wait 1 second before continuing
    
  }
  else
  {
    // PN532 probably timed out waiting for a card
    //Serial.println("Timed out waiting for a card");
  }
  delay(1000);
}

Writing assignment 3

Mel Jones

Network Everything

February 6, 2017

 

As more and more products such as the apple watch and google glass become available on the market, the possibility of a completely integrated system of wearable technology seems inevitable. In part, the idea of such a future is exciting as it could become possible for people to easily piece together every aspect of our lives and make it as efficient as possible. However, the repercussions of it are major. The pervasive nature of the technology makes for a complete lack of privacy and in return creates a constant over looming threat to our well being.  Furthermore the uses of the technology in its current state aren’t completely useful and direct interaction with the technology in some cases isn’t exactly as natural as it could possibly be. As described by author Gershenfeld, interacting with such software can be seen as “unstimulating” and “frequently overdone”.  Gershenfeld then offers a plausible explanation as to why some technological inventions contain this characteristic. The inability to understand the seriousness of a situation leads a computer to become out of touch with the person it is interacting with. It remains in a default state where it can be incapable of adapting to the needs of its user. In addition to this, computers can also slowly chip away at a person’s interest with their current surroundings. It makes the choice between the two a complicated handoff. However, it does have a few benefits that can completely revolutionize the way we go about using and thinking about technology. Having the ability to share information can increase the ease of human interaction by essentially collecting that data and use it to manipulate that very situation so that it can better cater to your needs and preferences. The use of this information essentially makes a network that thinks more so logistical than physical. This change in concept provides a greater amount of resources to pull from making seemingly large and insurmountable tasks doable by facilitating interactions that in some cases may never have been possible. In the future I would hope that such wearable technology can become more physically natural. Hopefully it will help me better understand my surroundings by pointing out potentially harmful things that I could never see with the naked eye. I also hope that it can in some way store certain memories that I select in order to prevent me from forgetting any costly information

 

Writing Assignment #1

The “internet of things” as described by Bruce Sterling is essentially a mirage of intellectual and creative progression. Underneath its façade lies a capitalist driven network of technology conglomerates who are engaged in an ongoing battle to not only have access to every move that you make, but more importantly control the flow of technology which influences our everyday decisions. Both Sterling and the owner of the IOS account agree to this on a certain level as they both make mention of the mass amount of products being pumped into the market, whose interconnectivity seem both forced and in general pretty useless.

It seems as though every tech companies dream is to have a future where every single aspect of living contains some certain type of interconnectedness that is controlled by one central network. As the internet of things inches closer to this possible reality, so comes product ideas and functions that lack a sense of individuality. A lot of products seem to be an exact copy or sloppy rendition of another product that has already been made and some even aim to take away the need to think or act for oneself. It is at this point that Sterling and the IOS account owner seem to differ in their opinion of the internet of things. Sterling seems to view the internet of things with a more cynical nature than IOS. The account owner of IOS sees a benefit in the internet of things, but simply believes that it is not being used to its greatest advantage unlike Sterling who seems to believe that the whole function of the internet of things is for purpose of maximizing the ability to create profit.

I tend to believe both Sterling and the IOS account owner are correct in their observations of the internet of things. I do believe that there is a some sort of capitalist hierarchy attached to the internet of things, but at the same time I also believe that not all of it is bad; However, to me it seems as though the main focus of the internet of things is and will always be money and that is why things such as the IOS account are so important. The IOS account not only reminds people to realize what it is they are doing and why, but it also shows the intrinsic value in creating something just for the sake of creating it. In a world full of where it seems as though everything is designed to work one way,  the ability to create something that is different and more importantly something that can challenge common thinking becomes more and more valuable. I believe that it is this factor that is being drowned out of the creative process behind the internet of things and is the main cause for most its products to overall feel same or even useless. This doesn’t mean that I think every product idea should be revolutionary. It just means that with a mindset of creating for profit, technology won’t progress as creatively and progressively as it could.

Final Project

For my final project I wanted to create something that was completely different from my midterm since my midterm did not create a good basis for interaction between the user and the sketch itself. So when approaching this I thought that the best way to get a user involved was to create a game since they are heavily based on user input.

The concept of the game itself is very simple. All that you have to do is use a joystick to move a  ball that bounces on the platforms given and attempt to hit a little red dot without allowing the ball to fall past the lowest level of platforms. With each hit the red dot relocates to a random position on the screen.

 

Here is an example of it working

 

 

 

 

 

 

So when first starting this final I  had absolutely no idea what to do until I came across an example  of pong,  a game that uses rectangles to bounce a ball across the screen. So taking from this game I built multiple platforms that could bounce a ball similar to pong, but rather than bouncing the ball horizontally I  flipped it and made the ball bounce vertically. After building the platforms I came up with the idea to add the red dot to give some type of motive to the game and then added statements to add the ability to control the direction of the bouncing ball.

Overall once I finally developed an idea building the processing side of the project went incredibly smoothly. It wasn’t until I tried to integrate Arduino that I started to run into major problems. When it came to coding for the joystick I was completely clueless and had to seek the help of some faculty members. My biggest problem was sending  data from the the joystick to the processing sketch. Once I was actually able to send data to processing all of the x and y axis movements of the joystick were being sent in one large list. After seeking even more help the data was then split and assigned to x and y position variables using  arrays. From there it was just a matter of using the variables to create if statements to assign the movement of the ball to the change in the sensor values.

 

 

So in all I now feel really confident in creating if statements for variables and in future I would like to be more efficient in using arrays in serial communication. I feel that by becoming comfortable with this I will be better at incorporating Arduino into my processing sketches.

 

 

 

Processing code:

import processing.serial.*;

int receivedX_value = 0;
int receivedY_value = 0;
int lineNumberReceived = 0;

Serial myPort;

String stringFromArduino;

float ballY;
float yspeed=-10;
float ballX;
float xspeed;
float dotX;
float dotY;
int score = 0;
boolean title = true;

int xPosition;
int yPosition;
int buttonState;

void setup()
{
  
  
  myPort = new Serial(this, Serial.list()[3], 9600);
  
  size(1225, 650);
  smooth();
  background(255);

  textSize(24);
  ballY=height-13;
  ballX=ballY;
  dotX = width/2;
  dotY = height/2;
}






void draw() {

  //When Arduino sends data to processing for the joystick it sends it all as one list
  //so you have to seperate it and place it into seperate variables so that 
  //you can then use the variables to move the ball left and right 
  
  
  
  while (myPort.available() > 0) {
    String serialStr = myPort.readStringUntil('n');
    if (serialStr != null) {
      try {
        String cleanDataString = serialStr.trim();
        String[] allSensorDataArray = split(cleanDataString, ',');
        if (allSensorDataArray.length == 3) {
          xPosition = Integer.parseInt(allSensorDataArray[0]);
          yPosition = Integer.parseInt(allSensorDataArray[1]);
          buttonState = Integer.parseInt(allSensorDataArray[2]);
        }
      }
      catch(NumberFormatException e) {
      }
    }
  }
  //println(xPosition, yPosition, buttonState);
  if(xPosition < 300) {
     println("left"); 
  }
  else if(xPosition > 700){
    println("right");
  }
  
  if(yPosition < 300) {
     println("down"); 
  }
  else if(yPosition > 700){
    println("up");
  }
  
  //once the data is seperated you have to create if statements that connect the left
  //and movements of the ball to the left and right movemnets of the joystick
  if(xPosition < 300) {
  xspeed = -3;
  }
 
 if(xPosition > 700) {
 xspeed = 3;
 
 }
 
 
  

  {
    background(45, 179, 221);
    fill(255, 255, 255, 100);
    stroke(#00FF00);
    rect(0, 0, width, height);

   
    
    //These rectangles are all of the platforms in the game
    fill(0);
    rect(50, 625, 75, 10);
    rect(225, 625, 75, 10);
    rect(400, 625, 75, 10);
    rect(575, 625, 75, 10);
    rect(750, 625, 75, 10);
    rect(925, 625, 75, 10);
    rect(1100, 625, 75, 10);
    rect(75, 540, 75, 10);
    rect(230, 225, 75, 10);
    rect(1000, 470, 75, 10);
    rect(800, 150, 75, 10);
    rect(900, 100, 75, 10);
    rect(630, 500, 75, 10);
    rect(400, 475, 75, 10);
    rect(425, 230, 75, 10);
    rect(830, 345, 75, 10);
    rect(1100, 250, 75, 10);
    rect(300, 325, 75, 10);
    rect(width/2, 275, 75, 10);
    rect(350, 125, 75, 10);
    rect(100, 350, 75, 10);
    rect(100, 150, 75, 10);

    fill(random (0, 255), 0, 100);
    ellipse(ballX, ballY, 25, 25);
    ballY = ballY + yspeed;
    
    //In examples that I saw for the game pong in order to bounce the ball back 
    //and for you had to reverse the speed once it contacts one of the rectangles
    //For my game in order to make the ball move upwards and reach the red dot at the top of the 
    //I had to add to the speed rather than reverse it
    yspeed = yspeed+.25;
    ballX = ballX + xspeed;


    
    //These if statements allow for the ball to bounce once coming into contact with a rectamgle
    //each statement works so that when the ball reaches the vicinity of a recdtangle the
    //sketch the knows to how far and fast to bounce the ball
    if (ballX >= 50 && ballX <= 125
      && ballY >= 605
      && ballY <= 630)
    {
      ballY = 605;
      yspeed = -10;
    }
    if (ballX >= 225 && ballX <= 300
      && ballY >= 605
      && ballY <= 630)
    {
      ballY = 605;
      yspeed = -10;
    }
    if (ballX >= 400 && ballX <= 475
      && ballY >= 605
      && ballY <= 630)
    {
      ballY = 605;
      yspeed = -10;
    } 
    if (ballX >= 575 && ballX <= 650
      && ballY >= 605
      && ballY <= 630)
    {
      ballY = 605;
      yspeed = -10;
    } 
    if (ballX >= 750 && ballX <= 825
      && ballY >= 605
      && ballY <= 630)
    {
      ballY = 605;
      yspeed = -10;
    } 
    if (ballX >= 925 && ballX <= 1000
      && ballY >= 605
      && ballY <= 630)
    {
      ballY = 605;
      yspeed = -10;
    } 
    if (ballX >= 1100 && ballX <= 1175
      && ballY >= 605
      && ballY <= 630)
    {
      ballY = 605;
      yspeed = -10;
    } 
    if (ballX >= 75 && ballX <= 150
      && ballY >= 520
      && ballY <= 545)
    {
      ballY = 520;
      yspeed = -10;
    }   
    if (ballX >= 230 && ballX <= 305
      && ballY >= 205
      && ballY <= 230)
    {
      ballY = 205;
      yspeed = -10;
    } 
    if (ballX >= 1000 && ballX <= 1075
      && ballY >= 450
      && ballY <= 475)
    {
      ballY = 450;
      yspeed = -10;
    } 
    if (ballX >= 800 && ballX <= 875
      && ballY >= 130
      && ballY <= 155)
    {
      ballY = 130;
      yspeed = -10;
    } 
    if (ballX >= 900 && ballX <= 975
      && ballY >= 80
      && ballY <= 105)
    {
      ballY = 80;
      yspeed = -10;
    } 
    if (ballX >= 630 && ballX <= 705
      && ballY >= 480
      && ballY <= 505)
    {
      ballY = 480;
      yspeed = -10;
    }
    if (ballX >= 400 && ballX <= 475
      && ballY >= 455
      && ballY <= 480)
    {
      ballY = 455;
      yspeed = -10;
    }  
    if (ballX >= 425 && ballX <= 500
      && ballY >= 210
      && ballY <= 235)
    {
      ballY = 210;
      yspeed = -10;
    }   
    if (ballX >= 830 && ballX <= 905
      && ballY >= 325
      && ballY <= 350)
    {
      ballY = 325;
      yspeed = -10;
    } 
    if (ballX >= 1100 && ballX <= 1175
      && ballY >= 230
      && ballY <= 255)
    {
      ballY = 230;
      yspeed = -10;
    } 
    if (ballX >= 300 && ballX <= 375
      && ballY >= 305
      && ballY <= 330)
    {
      ballY = 305;
      yspeed = -10;
    } 
    if (ballX >= 612.5 && ballX <= 687.5
      && ballY >= 255
      && ballY <= 280)
    {
      ballY = 255;
      yspeed = -10;
    } 
    if (ballX >= 350 && ballX <= 425
      && ballY >= 105
      && ballY <= 130)
    {
      ballY = 105;
      yspeed = -10;
    } 
    if (ballX >= 100 && ballX <= 175
      && ballY >= 330
      && ballY <= 355)
    {
      ballY = 330;
      yspeed = -10;
    } 
    if (ballX >= 100 && ballX <= 175
      && ballY >= 130
      && ballY <= 155)
    {
      ballY = 130;
      yspeed = -10;
    }   
    if (ballX >= width - 13)
    {
      ballX = width-13;
      xspeed = -3;
    }
    if (ballX <= 13)
    {
      ballX = 13;
      xspeed = 3;
    }
    if (ballY <= 13)
    {
      yspeed = 3;
    }
    
    //This statement allows for the dot to relocate randomly once it hit
    if (dist(ballX, ballY, dotX, dotY)<=13)
    {
      dotX = random(width - 15);
      dotY = random(height - 75);
      score++;
    }

    fill (255, 0, 0);
    ellipse ( dotX, dotY, 10, 10);

    fill(0);
    text("Score: " + score, 10, 25); 

   
    
    //This if statement shows the final page once the falls past the lowest level of 
    //platforms
    if (ballY >= 675)
    {
      textSize(50);
      background(0);
      fill(255, 0, 0);
      text("Game Over", 500, height/2);
      textSize(25);
      text("Score:" + score, 600, 380);
      textSize(15);
      text("Press Spacebar to RESTART", 550, 420);
      noLoop();
    }
  }
}




void keyPressed()
{

  //At first I used the keyboard to moe the ball in order to test if every was working
  //  if (keyCode == LEFT)
//  {
//    xspeed = -3;
//  }
//  if (keyCode == RIGHT)
//  {
//    xspeed = 3;
 // }
  
  
  //This if statement restarts the game only if both the space bar is pressed and the
  //ball is past the lowest level in order to avoid accidentally pressing the spacebar
  //during the game and restarting everything
  if ((key == ' ') && (ballY >= 675))
  {
    loop();
    //score=0;
    ballY=height-13;
    ballX=ballY;
    dotX = width/2;
    dotY = height/2;
    yspeed = -10;
    xspeed = 0;
  }
  

}



Arduino Code:


int xPosition = 0;
int yPosition = 0;
int buttonState = 0;

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600); 

  //activate pull-up resistor on the push-button pin
//  pinMode(buttonPin, INPUT_PULLUP); 
  
  // For versions prior to Arduino 1.0.1
  // pinMode(buttonPin, INPUT);
  // digitalWrite(buttonPin, HIGH);
  
}

void loop() {
  xPosition = analogRead(1);
  yPosition = analogRead(0);
  buttonState = 0;// digitalRead(buttonPin);
  
//  Serial.print("X: ");
  Serial.print(xPosition);
  Serial.print(",");
//  Serial.print(" | Y: ");
  Serial.print(yPosition);
  Serial.print(",");
//  Serial.print(" | Button: ");
  Serial.println(buttonState);

  delay(100); // add some delay between reads
}

Final Essay

To me Interaction can be described as technology that is focused around the flow of information between technology and its users in such a way that the users input data or requests that the technology can in return use to respond to the data in the form of some type of action.  In terms of technology in general,  technology serves as a pathway for the exchange of information between humans and computers.

When attempting to create an idea for my final project it was incredibly difficult for me to come up with an idea so I decided to take a step back and evaluate my midterm project.

After creating a music visualizer for my mid-term project I can see now that it didn’t really fit into the category of interaction as well as it could have.Although I like the idea of creating visuals I feel that my habit of creating rather stripped down and simplistic designs in return kind of hinders me from being able to create something that can engage people’s interest. My mid-term project rather than establishing some type of communication between the user and technology instead turned into something that was rather singular meaning that there was really nothing for the user to do except sit and watch leading it to become something that some people saw as rather unengaging and boring. So when I began to work on my final project I ended up coming up with ideas that in hindsight were a little too ambitious in the hopes of maybe solving this issue. Once I finally settled down and became realistic I decided that in order to sort of solve this issue I could create a game since they are heavily  reliant on user and computer communication. I figured that this could hopefully solve my engagement issue and also not cause me to feel pressured to create something too extravagant.

So for my final I wanted to create a sketch that could be controlled almost completely by the user in order to better establish some type of connectivity. After multiple idea changes I finally settled on the idea of creating a sketch based on the game of pong. The objective of the game is rather simple. All that it entails is  laterally maneuvering a ball in order to hit a red dot that is randomly placed on the screen. With each hit the dot then randomly relocates to a different section on the screen. The goal of the game is to use the platforms given to bounce the ball in the direction of the dot and hit it as many times as possible without allowing the ball to drop below the base level of platforms. To add a more physically stimulating aspect to the game I want to add a joystick to control the lateral movements of the ball. I feel that by creating this game and by making its premise simplistic I can actually make something that can engage people’s interest and also allow it to be used by as many people as possible.