Twerk The Logo

// ARDUINO CODE 

void setup()
{
    // put your setup code here, to run once:
    Serial.begin(9600);
}
void loop()
{
    // put your main code here, to run repeatedly:
    Serial.write(analogRead(A0) / 4);
    delay(100);
}
//Processing CODE

//including the serial ports external lybrary
import processing.serial.*;

// create an instance of the serial library
Serial myPort;

//Creating an object for the image
PImage logo;

//Creating a variable to hold the background colour
int bgcolor=0;

void setup() {
  // you can use "size(logo.width,logo.height)" to automatically adjust the scale
  //if you have problems, adjust it manually:
  size(1, 1);
  surface.setResizable(true);
  //Setting the colour mode. In this case we're useing HSB(HueSaturationBrightness). The hue will change while turning the potentiometer.
  colorMode(HSB, 255);

  //loading the image directly form the Internet
  logo=loadImage("http://arduino.cc/logo.png");

  // make the window the same size as the image
  surface.setSize(logo.width, logo.height);

  //Printing a list with all the serial ports your computer has when the program first starts.
  println("Available serial ports:");
  printArray(Serial.list());

  //Telling Processing information about the serial connection. The parameters are: which application will be speaking to, which serial port will be communicating(depending on the previous result), and at what speed.
  //myPort=new Serial(this,Serial.list()[1],9600);
  //myPort = new Serial(this, Serial.list()[1], 9600);
  myPort = new Serial(this, "/dev/cu.usbmodem141201", 9600);
}

//Analog function to void loop() in Arduino
void draw() {
  //if there is information in the serial port
  if (myPort.available()>0) {
    bgcolor=myPort.read();
    println(bgcolor);
  }

  //Draw the background. the variable bgcolor contains the Hue, determined by
  // the value from the serial port
  background(bgcolor, 255, 255);

  //Displaying the Arduino logo and starting drawing on top left (0.0)
  image(logo, 0, 0);
}