Intro to Physical Computing Syllabus

Research & Learning

Other Class pages

Shop Admin

ITP Help Pages
Tom's pcomp site
DanO's pcomp site


Sixth Week

Spring09.SixthWeek History

Hide minor edits - Show changes to markup

January 17, 2013, at 11:47 AM by asa200 -
Changed lines 18-19 from:
  • NIME,Pinch Glove, midi guitar
to:
  • NIME,Pinch Glove, midi guitar
March 05, 2009, at 12:28 AM by shf220 -
Added lines 1-27:

Code from class below

Notes on your midterms

  • sam griffin michael's inspirations
    • uva and the like
    • see also tony oursler
  • mindy & andrew & jee's
     **fun house inspired
  • see also ku
  • aron & k's
     **performative interfaces
  • Michel Waisvisz's hands, NIME
  • carbon & milena
     **Gloved performances
  • NIME,Pinch Glove, midi guitar
  • gordie, emily, liana
     **alternative interfaces
  • brian, laura
     **interactive kiosks, bringing people together in unexpected places like museums,cabinets of curiosities/wonder
March 05, 2009, at 12:10 AM by shf220 -
Changed lines 1-2 from:

Print out different data formats

to:

Punctuation Method :: Arduino code

Changed lines 4-6 from:

int analogPin = 0; int analogValue = 0; // integer to print

to:

int analogOne = 0; // analog input int analogTwo = 1; // analog input int digitalOne = 2; // digital input

int sensorValue = 0; // reading from the sensor

Changed line 11 from:
  // open serial communications at 9600 bps
to:
  // configure the serial connection:
Added lines 13-14:
  // configure the digital input:
  pinMode(digitalOne, INPUT);
Changed lines 18-33 from:
  // read the analog input, divide by 4:
  analogValue = analogRead(analogPin) /4;

  // print in many formats:
  Serial.print(analogValue, BYTE);     // Print the raw binary value analogValue
  Serial.print('\t');                  // print a tab
  Serial.print(analogValue, BIN);      // print the ASCII encoded binary analogValue
  Serial.print('\t');                  // print a tab
  Serial.print(analogValue, DEC);      // print the ASCII encoded decimal analogValue
  Serial.print('\t');                  // print a tab
  Serial.print(analogValue, HEX);      // print the ASCII encoded hexadecimal analogValue
  Serial.print('\t');                  // print a tab
  Serial.print(analogValue, OCT);      // print the ASCII encoded octal analogValue
  Serial.println();                    // print a linefeed and carriage return

  delay(10);
to:
  // read the sensor:
  sensorValue = analogRead(analogOne);
  // print the results:
  Serial.print(sensorValue, DEC);
  Serial.print(",");

  // read the sensor:
  sensorValue = analogRead(analogTwo);
  // print the results:
  Serial.print(sensorValue, DEC);
  Serial.print(",");

  // read the sensor:
  sensorValue = digitalRead(digitalOne);
  // print the last sensor value with a println() so that
  // each set of four readings prints on a line by itself:
  Serial.println(sensorValue, DEC);
Changed line 38 from:

Data from 2 sensors

to:

Punctuation:: Processing Code

Changed lines 40-47 from:

int analog1Pin = 0; int analog2Pin = 1;

int analog1Value = 0; // integer to print int analog2Value = 0; // integer to print

to:

import processing.serial.*; // import the Processing serial library Serial myPort; // The serial port

float bgcolor; // Background color float fgcolor; // Fill color float xpos, ypos; // Starting position of the ball

Changed lines 48-50 from:
  // open serial communications at 9600 bps
  Serial.begin(9600);
to:
  size(640,480);

  // List all the available serial ports
  println(Serial.list());

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

  // read bytes into a buffer until you get a linefeed (ASCII 10):
  myPort.bufferUntil('\n');

//don't draw a line around the circle

 noStroke();
Changed lines 61-68 from:

void loop() {

   for (int thisSensor = 0; thisSensor < 3; thisSensor++) {
      int sensorValue = analogRead(thisSensor);
      Serial.print(sensorValue, DEC);
      Serial.print(",");
   }
to:

void draw() {

  background(bgcolor);
  fill(fgcolor);
  // Draw the shape
  ellipse(xpos, ypos, 20, 20);
Added lines 68-98:

// serialEvent method is run automatically by the Processing applet // whenever the buffer reaches the byte value set in the bufferUntil() // method in the setup():

void serialEvent(Serial myPort) {

  // read the serial buffer:
  String myString = myPort.readStringUntil('\n');
  // if you got any bytes other than the linefeed:
  if (myString != null) {

    myString = trim(myString);

    // split the string at the commas
    // and convert the sections into integers:
    int sensors[] = int(split(myString, ','));

    // print out the values you got:
    for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
      print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t"); 
    }
    // add a linefeed after all the sensor values are printed:
    println();
    if (sensors.length > 1) {

//lab code has these values mapped to accelerometers, since I used a pot, i changed the mapping to 0, 1023 //adjust appropriately for your inputs

      xpos = map(sensors[0], 0,1023,0,width);
      ypos = map(sensors[1], 0,1023,0,height);
      fgcolor = sensors[2] * 255;
    }
  }

}

Changed lines 103-104 from:

Punctuation Method :: Ardy code

to:

call n response Method :: Ardy code

also referred to as handshake

Added lines 117-118:

establishContact();

Added lines 122-124:
  if (Serial.available() > 0) {
    // read the incoming byte:
    int inByte = Serial.read();
Added line 142:
  }
Added lines 145-152:

void establishContact() {

 while (Serial.available() <= 0) {
      Serial.println("hello");   // send a starting message
      delay(300);
  }

}

Changed line 155 from:

Punctuation:: Processing

to:

call n response:: Processing

Added lines 164-165:

boolean firstContact = false; // Whether we've heard from the microcontroller

Added lines 172-175:
  // I know that the first port in the serial list on my mac
  // is always my  Arduino module, so I open Serial.list()[0].
  // Change the 0 to the appropriate number of the serial port
  // that your microcontroller is attached to.
Added lines 180-181:

//don't draw a line aroundf the ellipse noStroke();

Changed lines 203-209 from:
    // split the string at the commas
    // and convert the sections into integers:
    int sensors[] = int(split(myString, ','));

    // print out the values you got:
    for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
      print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t"); 
to:
    // if you haven't heard from the microncontroller yet, listen:
    if (firstContact == false) {
      if (myString.equals("hello")) { 
        myPort.clear();          // clear the serial port buffer
        firstContact = true;     // you've had first contact from the microcontroller
        myPort.write('A');       // ask for more
      } 
    } 
    // if you have heard from the microcontroller, proceed:
    else {
      // split the string at the commas
      // and convert the sections into integers:
      int sensors[] = int(split(myString, ','));

      // print out the values you got:
      for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
        print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t"); 
      }
      // add a linefeed after all the sensor values are printed:
      println();
      if (sensors.length > 1) {

//lab code has these values mapped to accelerometers, since I used a pot, i changed the mapping to 0, 1023 //adjust appropriately for your inputs

      xpos = map(sensors[0], 0,1023,0,width);
      ypos = map(sensors[1], 0,1023,0,height);
        fgcolor = sensors[2] * 255;
      }
Changed lines 231-237 from:
    // add a linefeed after all the sensor values are printed:
    println();
    if (sensors.length > 1) {
      xpos = map(sensors[0], 430,580,0,width);
      ypos = map(sensors[1], 430,580,0,height);
      fgcolor = sensors[2] * 255;
    }
to:
    // when you've parsed the data you have, ask for more:
    myPort.write("A");
Deleted lines 234-252:

@]

call n response Method :: Ardy code [@ int analogOne = 0; // analog input int analogTwo = 1; // analog input int digitalOne = 2; // digital input

int sensorValue = 0; // reading from the sensor

void setup() {

  // configure the serial connection:
  Serial.begin(9600);
  // configure the digital input:
  pinMode(digitalOne, INPUT);

establishContact();

Deleted lines 235-346:

void loop() {

  if (Serial.available() > 0) {
    // read the incoming byte:
    int inByte = Serial.read();
  // read the sensor:
  sensorValue = analogRead(analogOne);
  // print the results:
  Serial.print(sensorValue, DEC);
  Serial.print(",");

  // read the sensor:
  sensorValue = analogRead(analogTwo);
  // print the results:
  Serial.print(sensorValue, DEC);
  Serial.print(",");

  // read the sensor:
  sensorValue = digitalRead(digitalOne);
  // print the last sensor value with a println() so that
  // each set of four readings prints on a line by itself:
  Serial.println(sensorValue, DEC);
  }

}

void establishContact() {

 while (Serial.available() <= 0) {
      Serial.println("hello");   // send a starting message
      delay(300);
  }

}

@]

call n response:: Processing [@ import processing.serial.*; // import the Processing serial library Serial myPort; // The serial port

float bgcolor; // Background color float fgcolor; // Fill color float xpos, ypos; // Starting position of the ball

boolean firstContact = false; // Whether we've heard from the microcontroller

void setup() {

  size(640,480);

  // List all the available serial ports
  println(Serial.list());

  // I know that the first port in the serial list on my mac
  // is always my  Arduino module, so I open Serial.list()[0].
  // Change the 0 to the appropriate number of the serial port
  // that your microcontroller is attached to.
  myPort = new Serial(this, Serial.list()[0], 9600);

  // read bytes into a buffer until you get a linefeed (ASCII 10):
  myPort.bufferUntil('\n');

}

void draw() {

  background(bgcolor);
  fill(fgcolor);
  // Draw the shape
  ellipse(xpos, ypos, 20, 20);

}

// serialEvent method is run automatically by the Processing applet // whenever the buffer reaches the byte value set in the bufferUntil() // method in the setup():

void serialEvent(Serial myPort) {

  // read the serial buffer:
  String myString = myPort.readStringUntil('\n');
  // if you got any bytes other than the linefeed:
  if (myString != null) {

    myString = trim(myString);

    // if you haven't heard from the microncontroller yet, listen:
    if (firstContact == false) {
      if (myString.equals("hello")) { 
        myPort.clear();          // clear the serial port buffer
        firstContact = true;     // you've had first contact from the microcontroller
        myPort.write('A');       // ask for more
      } 
    } 
    // if you have heard from the microcontroller, proceed:
    else {
      // split the string at the commas
      // and convert the sections into integers:
      int sensors[] = int(split(myString, ','));

      // print out the values you got:
      for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
        print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t"); 
      }
      // add a linefeed after all the sensor values are printed:
      println();
      if (sensors.length > 1) {
        xpos = map(sensors[0], 430,580,0,width);
        ypos = map(sensors[1], 430,580,0,height);
        fgcolor = sensors[2] * 255;
      }
    }
    // when you've parsed the data you have, ask for more:
    myPort.write("A");
  }

} }

February 25, 2009, at 05:49 PM by shf220 -
Added lines 1-287:

Print out different data formats

int analogPin = 0;
int analogValue = 0;                // integer to print

void setup() {
  // open serial communications at 9600 bps
  Serial.begin(9600);
}

void loop() {
  // read the analog input, divide by 4:
  analogValue = analogRead(analogPin) /4;

  // print in many formats:
  Serial.print(analogValue, BYTE);     // Print the raw binary value analogValue
  Serial.print('\t');                  // print a tab
  Serial.print(analogValue, BIN);      // print the ASCII encoded binary analogValue
  Serial.print('\t');                  // print a tab
  Serial.print(analogValue, DEC);      // print the ASCII encoded decimal analogValue
  Serial.print('\t');                  // print a tab
  Serial.print(analogValue, HEX);      // print the ASCII encoded hexadecimal analogValue
  Serial.print('\t');                  // print a tab
  Serial.print(analogValue, OCT);      // print the ASCII encoded octal analogValue
  Serial.println();                    // print a linefeed and carriage return

  delay(10);
}

Data from 2 sensors

int analog1Pin = 0;
int analog2Pin = 1;


int analog1Value = 0;                // integer to print
int analog2Value = 0;                // integer to print


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

}



void loop() {
   for (int thisSensor = 0; thisSensor < 3; thisSensor++) {
      int sensorValue = analogRead(thisSensor);
      Serial.print(sensorValue, DEC);
      Serial.print(",");
   }
}

Punctuation Method :: Ardy code

int analogOne = 0;       // analog input 
int analogTwo = 1;       // analog input 
int digitalOne = 2;      // digital input 

int sensorValue = 0;     // reading from the sensor

void setup() {
  // configure the serial connection:
  Serial.begin(9600);
  // configure the digital input:
  pinMode(digitalOne, INPUT);
}

void loop() {
  // read the sensor:
  sensorValue = analogRead(analogOne);
  // print the results:
  Serial.print(sensorValue, DEC);
  Serial.print(",");

  // read the sensor:
  sensorValue = analogRead(analogTwo);
  // print the results:
  Serial.print(sensorValue, DEC);
  Serial.print(",");

  // read the sensor:
  sensorValue = digitalRead(digitalOne);
  // print the last sensor value with a println() so that
  // each set of four readings prints on a line by itself:
  Serial.println(sensorValue, DEC);
}

Punctuation:: Processing

import processing.serial.*;     // import the Processing serial library
Serial myPort;                  // The serial port

float bgcolor;			     // Background color
float fgcolor;			     // Fill color
float xpos, ypos;		             // Starting position of the ball

void setup() {
  size(640,480);

  // List all the available serial ports
  println(Serial.list());

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

  // read bytes into a buffer until you get a linefeed (ASCII 10):
  myPort.bufferUntil('\n');
}

void draw() {
  background(bgcolor);
  fill(fgcolor);
  // Draw the shape
  ellipse(xpos, ypos, 20, 20);
}

// serialEvent  method is run automatically by the Processing applet
// whenever the buffer reaches the  byte value set in the bufferUntil() 
// method in the setup():

void serialEvent(Serial myPort) { 
  // read the serial buffer:
  String myString = myPort.readStringUntil('\n');
  // if you got any bytes other than the linefeed:
  if (myString != null) {

    myString = trim(myString);

    // split the string at the commas
    // and convert the sections into integers:
    int sensors[] = int(split(myString, ','));

    // print out the values you got:
    for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
      print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t"); 
    }
    // add a linefeed after all the sensor values are printed:
    println();
    if (sensors.length > 1) {
      xpos = map(sensors[0], 430,580,0,width);
      ypos = map(sensors[1], 430,580,0,height);
      fgcolor = sensors[2] * 255;
    }
  }
}

call n response Method :: Ardy code

int analogOne = 0;       // analog input 
int analogTwo = 1;       // analog input 
int digitalOne = 2;      // digital input 

int sensorValue = 0;     // reading from the sensor

void setup() {
  // configure the serial connection:
  Serial.begin(9600);
  // configure the digital input:
  pinMode(digitalOne, INPUT);

establishContact(); 
}

void loop() {
  if (Serial.available() > 0) {
    // read the incoming byte:
    int inByte = Serial.read();
  // read the sensor:
  sensorValue = analogRead(analogOne);
  // print the results:
  Serial.print(sensorValue, DEC);
  Serial.print(",");

  // read the sensor:
  sensorValue = analogRead(analogTwo);
  // print the results:
  Serial.print(sensorValue, DEC);
  Serial.print(",");

  // read the sensor:
  sensorValue = digitalRead(digitalOne);
  // print the last sensor value with a println() so that
  // each set of four readings prints on a line by itself:
  Serial.println(sensorValue, DEC);
  }
}

void establishContact() {
 while (Serial.available() <= 0) {
      Serial.println("hello");   // send a starting message
      delay(300);
  }
}


call n response:: Processing

import processing.serial.*;     // import the Processing serial library
Serial myPort;                  // The serial port

float bgcolor;			     // Background color
float fgcolor;			     // Fill color
float xpos, ypos;		             // Starting position of the ball

boolean firstContact = false; // Whether we've heard from the microcontroller 

void setup() {
  size(640,480);

  // List all the available serial ports
  println(Serial.list());

  // I know that the first port in the serial list on my mac
  // is always my  Arduino module, so I open Serial.list()[0].
  // Change the 0 to the appropriate number of the serial port
  // that your microcontroller is attached to.
  myPort = new Serial(this, Serial.list()[0], 9600);

  // read bytes into a buffer until you get a linefeed (ASCII 10):
  myPort.bufferUntil('\n');
}

void draw() {
  background(bgcolor);
  fill(fgcolor);
  // Draw the shape
  ellipse(xpos, ypos, 20, 20);
}

// serialEvent  method is run automatically by the Processing applet
// whenever the buffer reaches the  byte value set in the bufferUntil() 
// method in the setup():

void serialEvent(Serial myPort) { 
  // read the serial buffer:
  String myString = myPort.readStringUntil('\n');
  // if you got any bytes other than the linefeed:
  if (myString != null) {

    myString = trim(myString);

    // if you haven't heard from the microncontroller yet, listen:
    if (firstContact == false) {
      if (myString.equals("hello")) { 
        myPort.clear();          // clear the serial port buffer
        firstContact = true;     // you've had first contact from the microcontroller
        myPort.write('A');       // ask for more
      } 
    } 
    // if you have heard from the microcontroller, proceed:
    else {
      // split the string at the commas
      // and convert the sections into integers:
      int sensors[] = int(split(myString, ','));

      // print out the values you got:
      for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
        print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t"); 
      }
      // add a linefeed after all the sensor values are printed:
      println();
      if (sensors.length > 1) {
        xpos = map(sensors[0], 430,580,0,width);
        ypos = map(sensors[1], 430,580,0,height);
        fgcolor = sensors[2] * 255;
      }
    }
    // when you've parsed the data you have, ask for more:
    myPort.write("A");
  }
}
}
  Edit | View | History | Print | Recent Changes | Search Page last modified on January 17, 2013, at 11:47 AM