Intro to Physical Computing Syllabus

Research & Learning

Other Class pages

Shop Admin

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


Dano Wed

Fall09.DanoWed History

Hide minor edits - Show changes to markup

November 13, 2009, at 11:55 AM by dbo3 -
Changed lines 24-25 from:
to:
  1. Melanie Clemmons
Deleted lines 26-27:
  1. Christine Nguyen" <cqn200@nyu.edu>
  2. David Phillips" <dp1244@nyu.edu>
Changed line 28 from:
  1. Hana Newman
to:
  1. David Phillips" <dp1244@nyu.edu>
Added lines 30-32:
  1. Michelle Temple
  2. Steve Aquillano
  3. Mike Knuepfel" <mk3321@nyu.edu>
Changed lines 34-36 from:
  1. Melanie Clemmons
to:
  1. Christine Nguyen" <cqn200@nyu.edu>
  2. Hana Newman
Deleted line 37:
  1. Michelle Temple
Deleted line 41:
  1. Steve Aquillano
Changed lines 44-45 from:
  1. Mike Knuepfel" <mk3321@nyu.edu>
to:
November 13, 2009, at 11:00 AM by dbo3 -
Changed lines 469-472 from:

Week 8

Week 9

to:
Changed lines 471-591 from:
to:
  • http://www.sparkfun.com/commerce/product_info.php?products_id=8880
  • http://www.sparkfun.com/commerce/product_info.php?products_id=256
  • http://www.sparkfun.com/commerce/product_info.php?products_id=400
  • http://www.sparkfun.com/commerce/product_info.php?products_id=7904
  • http://www.sparkfun.com/commerce/product_info.php?products_id=8960
  • http://www.sparkfun.com/commerce/product_info.php?products_id=8958
  • http://www.sparkfun.com/commerce/product_info.php?products_id=8940
  • http://www.sparkfun.com/commerce/product_info.php?products_id=8881
  • http://www.sparkfun.com/commerce/product_info.php?products_id=8633
  • http://www.sparkfun.com/commerce/product_info.php?products_id=8869
  • http://www.sparkfun.com/commerce/product_info.php?products_id=8852
  • http://www.sparkfun.com/commerce/product_info.php?products_id=8416
  • http://www.sparkfun.com/commerce/product_info.php?products_id=8627
  • http://www.sparkfun.com/commerce/product_info.php?products_id=8661
  • http://www.sparkfun.com/commerce/product_info.php?products_id=8128
  • http://www.sparkfun.com/commerce/product_info.php?products_id=8579
  • http://www.sparkfun.com/commerce/product_info.php?products_id=525

int r,g,b;

void setup() {

  Serial.begin(9600);  //set up communication back to pc
  //don't forget to press "serial monitor button"

}

void loop() {

  int analogReading = analogRead(5); //can only use pins 0-5
  Serial.print(analogReading);
  Serial.print(",");
  analogReading = analogRead(4); //can only use pins 0-5
  Serial.print(analogReading);
  Serial.print(",");
  analogReading = analogRead(3); //can only use pins 0-5
  Serial.print(analogReading);
  Serial.print(",");
  Serial.println(10,BYTE); //talk back to pc
  if (Serial.available() >=3){
    r = Serial.read();
    g = Serial.read();
    b = Serial.read();
  }
  analogWrite(6,b);
  analogWrite(5,r);
  analogWrite(3,g);
  delay(20);

}


import processing.serial.*; Serial port; // The serial port

int xpos, ypos; // position of the ball

int r,g,b; PImage pic ;

void setup() {

  size(255, 255);  // Stage size
  pic = loadImage("colorspace_RGB.png");
  ellipseMode(CENTER);
  size(pic.width,pic.height);
  xpos = width/2;
  ypos = height/2;
  // Print a list of the serial ports, for debugging purposes to find out what your ports are called:
  println(Serial.list());
  //port = new Serial(this, Serial.list()[0], 9600);  //you can pull the name out of the list
  port = new Serial(this, "/dev/tty.usbserial-A7004nUQ", 9600);  //or you can just specify it
  sendColors();  // Send stuff in case the microcontroller is waiting to hear from you

}

void sendColors(){

  port.write(r);
  port.write(g);
  port.write(b); 

}

void draw() {

  //image of a color space
  image(pic,0,0);

  /*  draw a color space
   for(int i=0; i<width; i++) {
   for(int j=0; j<height; j++) {
   stroke(0, i, j);
   point(i, j);
   }
   }
   */
  //find the color of the pixel at the current spot
  int thisPixel = get(xpos,ypos);
  r = int(red(thisPixel));
  g = int(green(thisPixel));
  b = int(blue(thisPixel));
  //put an ellipse over the spot
  fill(255,255,255);
  ellipse(xpos,ypos,10,10);

}

void serialEvent(Serial port) {

  String input = port.readStringUntil(10);  //make sure you return (Ascii 13) at the end of your transmission
  if (input != null){
    print("Raw Input: " + input);
    String[] parts = input.split(",");  //this will only work if you put commas (Ascii 44) between things in your transmission
    if (parts.length > 2){ //make sure it is a full valid message
      int xtilt = int(parts[0]);
      int ytilt = int(parts[1]);
      xpos = int( map(xtilt,400,600,0,width) );
      ypos = int( map(ytilt,400,600,0,height) );
      sendColors();
    }
  }

}

Week 10

October 20, 2009, at 03:15 PM by dbo3 -
Changed lines 247-250 from:

Week 6 ACCELEROMETER + RGB LED

ARDUINO SIDE

to:

Week 7 ACCELEROMETER + RGB LED

ARDUINO SIDE

Changed lines 284-285 from:

PROCESSING SIDE import processing.serial.*;

to:

PROCESSING SIDE import processing.serial.*;

October 20, 2009, at 03:15 PM by dbo3 -
Changed lines 140-145 from:

Week 6 ACCELEROMETER + RGB LED

ARDUINO SIDE

int analogReading; //variable int size because adc number potentially as big as 1024

to:

Week 7

Arduino

 int heat = 65; int light = 65; int onOff = 0;
Changed lines 147-149 from:
  beginSerial(9600);  //set up communication back to pc
  //don't forget to press "serial monitor button"
to:
  Serial.begin(9600);
  pinMode(4, INPUT); 
  pinMode(7, OUTPUT); 
  Serial.println("Start");
Changed lines 155-171 from:
  analogReading = analogRead(5); //can only use pins 0-5
  Serial.print(analogReading,DEC);
  Serial.print(44,BYTE);
  analogReading = analogRead(4); //can only use pins 0-5
  Serial.print(analogReading,DEC);
  Serial.print(44,BYTE);
  analogReading = analogRead(3); //can only use pins 0-5
  Serial.print(analogReading,DEC);
  Serial.print(44,BYTE);
  Serial.println(10,BYTE); //talk back to pc
  if (Serial.available() >=3){
    int r = Serial.read();
    int g = Serial.read();
    int b = Serial.read();
    analogWrite(6,b);
    analogWrite(5,6);
    analogWrite(11,g);
to:
  if (Serial.available() > 0){  //only send if you have hear back
    int input = Serial.read();
    input = map(input,0,255,500,2500);    // convert the analog value
    // to a range between minPulse
    Serial.println(input);
    digitalWrite(7, HIGH);   // Turn the motor on
    delayMicroseconds(input);       // Length of the pulse sets the motor position
    digitalWrite(7, LOW);    // Turn the motor off

    heat  = analogRead(5);
    light  = analogRead(0);
    onOff = digitalRead(4);

    Serial.print(heat);
    Serial.print(",");
    Serial.print(light);
    Serial.print(",");
    Serial.print(onOff);
    Serial.print(",");

    Serial.print(10, BYTE);  //send a return
    //Serial.flush();
   delay(20);  //you might use this instead of if available
Changed lines 179-180 from:
  delay(20);
to:
Changed lines 183-186 from:

PROCESSING SIDE import processing.serial.*;

Serial port; // The serial port int xpos, ypos; // position of the ball int r,g,b;

to:

Procressing

import processing.serial.*;

float bgColor; // Background color

Serial port; // The serial port float xpos; // position of the ball float ypos ; int shape;

Changed lines 196-197 from:
  size(255, 255);  // Stage size
to:
  size(800, 600);  // Stage size
  ypos = height*3/4;
  xpos = width/4;
  noStroke();      // No border on the next thing drawn
Changed lines 201-203 from:
  xpos = width/2;
  ypos = height/2;
to:
  rectMode(CENTER);
Changed lines 205-208 from:
  //port = new Serial(this, Serial.list()[0], 9600);  //you can pull the name out of the list
  port = new Serial(this, "COM28", 9600);  //or you can just specify it
  sendColors();  // Send stuff in case the microcontroller is waiting to hear from you
to:
  port = new Serial(this, Serial.list()[0], 9600);  //you can pull the name out of the list
  //port = new Serial(this, "/dev/tty.BlueRadios-COM0-1", 9600);  //or you can just specify it
  port.write(65);    // Send a capital A in case the microcontroller is waiting to hear from you
  // println("OKAY LET'S GO");
Deleted lines 211-219:

void sendColors(){

  port.write(r);
  port.write(g);
  port.write(b); 
  //println("R" + r+ " G" + g + " B" + b);

}

Changed lines 214-217 from:
  for(int i=0; i<width; i++) {
  for(int j=0; j<height; j++) {
    stroke(0, i, j);
    point(i, j);
to:
  background(0);
  fill(255-bgColor,0,0);
  // Draw the shape
  if (shape == 0){
    ellipse(xpos, ypos, 60, 60);
Changed lines 220-223 from:
to:
  else{
    rect(xpos, ypos, 60, 60);
  }
Deleted lines 225-233:
  int thisPixel = get(xpos,ypos);
  r = int(red(thisPixel));
  g = int(green(thisPixel));
  b = int(blue(thisPixel));
  fill(255,255,255);
  ellipse(xpos,ypos,10,10);

}

Changed lines 232-253 from:
    if (parts.length > 2){ //make sure it is a full valid message
      //turn them from ASCII into numbers
      int xtilt = int(parts[0]);
      int ytilt = int(parts[1]);
      if (xtilt > 500) {
        xpos = xpos + 1 ;// same as xpos++
      }
      else {
        xpos = xpos - 1 ;// same as xpos--
      }
      xpos = min(xpos,width);
      xpos = max(xpos,0);
      if (ytilt > 500) {
        ypos = ypos + 1 ;// same as ypos++
      }
      else {
        ypos = ypos - 1 ;// same as ypos--
      }
      ypos = min(ypos,width);
      ypos = max(ypos,0);
      println("Positionx:" + xpos + " y:" + ypos );
      sendColors();
to:
    if (parts.length >= 3){
      ypos = int(parts[0]);
      ypos = map(ypos,300,900,height,0);  //400 and 625 were arrived at emperically by looking at readings from the sensor
      bgColor =  int(parts[1]);
      bgColor = map(bgColor,430,550,0,255); 
      shape = int(parts[2]);
      float mouseDistanceAcross = map(mouseX,0,width,0,255);
      port.write(int(mouseDistanceAcross)); //in this example you might use the mouse distance across to control the panning of a servo motor
Changed lines 246-251 from:

2 analog, 1 switch and a servo

ARDUINO

int heat = 65; int light = 65; int onOff = 0;

to:

Week 6 ACCELEROMETER + RGB LED

ARDUINO SIDE

int analogReading; //variable int size because adc number potentially as big as 1024

Changed lines 255-258 from:
  beginSerial(9600);
  pinMode(4, INPUT); 
  pinMode(2, OUTPUT); 
to:
  beginSerial(9600);  //set up communication back to pc
  //don't forget to press "serial monitor button"
Changed lines 262-283 from:
  if (Serial.available() > 0){  //only send if you have hear back
    int input = Serial.read();
    input = map(input,0,255,500,2500);    // convert the analog value
    // to a range between minPulse
    digitalWrite(2, HIGH);   // Turn the motor on
    delayMicroseconds(input);       // Length of the pulse sets the motor position
    digitalWrite(2, LOW);    // Turn the motor off


    heat  = analogRead(5);
    light  = analogRead(0);
    onOff = digitalRead(4);

    Serial.print(heat,DEC);
    Serial.print(44, BYTE);
    Serial.print(light,DEC);
    Serial.print(44, BYTE);
    Serial.print(onOff,DEC);
    Serial.print(44, BYTE);

    Serial.print(10, BYTE);  //send a return
    delay(20);  //you might use this instead of if available
to:
  analogReading = analogRead(5); //can only use pins 0-5
  Serial.print(analogReading,DEC);
  Serial.print(44,BYTE);
  analogReading = analogRead(4); //can only use pins 0-5
  Serial.print(analogReading,DEC);
  Serial.print(44,BYTE);
  analogReading = analogRead(3); //can only use pins 0-5
  Serial.print(analogReading,DEC);
  Serial.print(44,BYTE);
  Serial.println(10,BYTE); //talk back to pc
  if (Serial.available() >=3){
    int r = Serial.read();
    int g = Serial.read();
    int b = Serial.read();
    analogWrite(6,b);
    analogWrite(5,6);
    analogWrite(11,g);
Changed lines 280-281 from:
to:
  delay(20);
Changed lines 284-289 from:

PROCESSING import processing.serial.*;

float bgColor; // Background color

Serial port; // The serial port float xpos; // position of the ball int shape;

to:

PROCESSING SIDE import processing.serial.*;

Serial port; // The serial port int xpos, ypos; // position of the ball int r,g,b;

Changed lines 290-291 from:
  size(256, 256);  // Stage size
  noStroke();      // No border on the next thing drawn
to:
  size(255, 255);  // Stage size
Changed lines 293-294 from:
  rectMode(CENTER);
to:
  xpos = width/2;
  ypos = height/2;
Changed lines 299-302 from:
  port = new Serial(this, "COM30", 9600);  //or you can just specify it
  port.write(65);    // Send a capital A in case the microcontroller is waiting to hear from you
  // println("OKAY LET'S GO");
to:
  port = new Serial(this, "COM28", 9600);  //or you can just specify it
  sendColors();  // Send stuff in case the microcontroller is waiting to hear from you
Added lines 304-312:

void sendColors(){

  port.write(r);
  port.write(g);
  port.write(b); 
  //println("R" + r+ " G" + g + " B" + b);

}

Changed lines 315-319 from:
  background(bgColor);
  fill(255,0,0);
  // Draw the shape
  if (shape == 0){
    ellipse(xpos, height/2, 20, 20);
to:
  for(int i=0; i<width; i++) {
  for(int j=0; j<height; j++) {
    stroke(0, i, j);
    point(i, j);
Changed lines 320-323 from:
  else{
    rect(xpos, height/2, 20, 20);
  }
to:
Added lines 323-331:
  int thisPixel = get(xpos,ypos);
  r = int(red(thisPixel));
  g = int(green(thisPixel));
  b = int(blue(thisPixel));
  fill(255,255,255);
  ellipse(xpos,ypos,10,10);

}

Changed line 336 from:
    println("Raw Input: " + input);
to:
    print("Raw Input: " + input);
Changed lines 338-350 from:
    if (parts.length >= 3){


      bgColor =  int(parts[0]);
      bgColor = map(bgColor,500,1000,0,255);  

      xpos = int(parts[1]);
      xpos = map(xpos,500,580,0,width);  //400 and 625 were arrived at emperically by looking at readings from the sensor

      shape = int(parts[2]);

      float mouseDistanceAcross = map(mouseX,0,width,0,255);
      port.write(int(mouseDistanceAcross)); //in this example you might use the mouse distance across to control the panning of a servo motor
to:
    if (parts.length > 2){ //make sure it is a full valid message
      //turn them from ASCII into numbers
      int xtilt = int(parts[0]);
      int ytilt = int(parts[1]);
      if (xtilt > 500) {
        xpos = xpos + 1 ;// same as xpos++
      }
      else {
        xpos = xpos - 1 ;// same as xpos--
      }
      xpos = min(xpos,width);
      xpos = max(xpos,0);
      if (ytilt > 500) {
        ypos = ypos + 1 ;// same as ypos++
      }
      else {
        ypos = ypos - 1 ;// same as ypos--
      }
      ypos = min(ypos,width);
      ypos = max(ypos,0);
      println("Positionx:" + xpos + " y:" + ypos );
      sendColors();
Added lines 363-464:

}

2 analog, 1 switch and a servo

ARDUINO

int heat = 65; int light = 65; int onOff = 0;

void setup() {

  beginSerial(9600);
  pinMode(4, INPUT); 
  pinMode(2, OUTPUT); 

}

void loop() {

  if (Serial.available() > 0){  //only send if you have hear back
    int input = Serial.read();
    input = map(input,0,255,500,2500);    // convert the analog value
    // to a range between minPulse
    digitalWrite(2, HIGH);   // Turn the motor on
    delayMicroseconds(input);       // Length of the pulse sets the motor position
    digitalWrite(2, LOW);    // Turn the motor off


    heat  = analogRead(5);
    light  = analogRead(0);
    onOff = digitalRead(4);

    Serial.print(heat,DEC);
    Serial.print(44, BYTE);
    Serial.print(light,DEC);
    Serial.print(44, BYTE);
    Serial.print(onOff,DEC);
    Serial.print(44, BYTE);

    Serial.print(10, BYTE);  //send a return
    delay(20);  //you might use this instead of if available
  }

}

PROCESSING import processing.serial.*;

float bgColor; // Background color

Serial port; // The serial port float xpos; // position of the ball int shape;

void setup() {

  size(256, 256);  // Stage size
  noStroke();      // No border on the next thing drawn
  ellipseMode(CENTER);
  rectMode(CENTER);

  // Print a list of the serial ports, for debugging purposes to find out what your ports are called:
  println(Serial.list());
  //port = new Serial(this, Serial.list()[0], 9600);  //you can pull the name out of the list
  port = new Serial(this, "COM30", 9600);  //or you can just specify it
  port.write(65);    // Send a capital A in case the microcontroller is waiting to hear from you
  // println("OKAY LET'S GO");

}

void draw() {

  background(bgColor);
  fill(255,0,0);
  // Draw the shape
  if (shape == 0){
    ellipse(xpos, height/2, 20, 20);
  }
  else{
    rect(xpos, height/2, 20, 20);
  }

}

void serialEvent(Serial port) {

  String input = port.readStringUntil(10);  //make sure you return (Ascii 13) at the end of your transmission
  if (input != null){
    println("Raw Input: " + input);
    String[] parts = input.split(",");  //this will only work if you put commas (Ascii 44) between things in your transmission
    if (parts.length >= 3){


      bgColor =  int(parts[0]);
      bgColor = map(bgColor,500,1000,0,255);  

      xpos = int(parts[1]);
      xpos = map(xpos,500,580,0,width);  //400 and 625 were arrived at emperically by looking at readings from the sensor

      shape = int(parts[2]);

      float mouseDistanceAcross = map(mouseX,0,width,0,255);
      port.write(int(mouseDistanceAcross)); //in this example you might use the mouse distance across to control the panning of a servo motor
    }
  }
October 16, 2009, at 11:16 AM by mfc312 -
Changed line 33 from:
  1. Melissa Clarke" <mfc312@nyu.edu>
to:
  1. Melissa Clarke" <mcnco@earthlink.net>
October 13, 2009, at 09:37 AM by dbo3 -
Changed lines 82-85 from:

Week 5

Week 6

to:
    * PROCESSING CIRCLE 

import processing.serial.*;

Serial myPort; int input;

void setup(){

  size(800,600);
  println(Serial.list());
  myPort = new Serial(this, "COM28", 9600); 
  ellipseMode(CENTER);

}

void draw(){

  background(255);
  ellipse(width/2,height/2,input*5,input*5);

} void serialEvent(Serial p) {

  input = p.read();
  println("input" + input);

}

    * PROCESSING GRAPH 

import processing.serial.*;

Serial myPort; int input; int xpos;

void setup(){

  size(800,600);
  println(Serial.list());
  myPort = new Serial(this, "COM28", 9600); 
  background(255);

}

void draw(){

  ellipse(xpos,input,2,2);
  xpos++;
  if (xpos > width){
    xpos = 0;
    background(255);
  }

} void serialEvent(Serial p) {

  input = p.read();
  println("input" + input);

}

Week 6 ACCELEROMETER + RGB LED

ARDUINO SIDE

int analogReading; //variable int size because adc number potentially as big as 1024

void setup() {

  beginSerial(9600);  //set up communication back to pc
  //don't forget to press "serial monitor button"

}

void loop() {

  analogReading = analogRead(5); //can only use pins 0-5
  Serial.print(analogReading,DEC);
  Serial.print(44,BYTE);
  analogReading = analogRead(4); //can only use pins 0-5
  Serial.print(analogReading,DEC);
  Serial.print(44,BYTE);
  analogReading = analogRead(3); //can only use pins 0-5
  Serial.print(analogReading,DEC);
  Serial.print(44,BYTE);
  Serial.println(10,BYTE); //talk back to pc
  if (Serial.available() >=3){
    int r = Serial.read();
    int g = Serial.read();
    int b = Serial.read();
    analogWrite(6,b);
    analogWrite(5,6);
    analogWrite(11,g);
  }
  delay(20);

}

PROCESSING SIDE import processing.serial.*;

Serial port; // The serial port int xpos, ypos; // position of the ball int r,g,b;

void setup() {

  size(255, 255);  // Stage size

  ellipseMode(CENTER);

  xpos = width/2;
  ypos = height/2;
  // Print a list of the serial ports, for debugging purposes to find out what your ports are called:
  println(Serial.list());
  //port = new Serial(this, Serial.list()[0], 9600);  //you can pull the name out of the list
  port = new Serial(this, "COM28", 9600);  //or you can just specify it
  sendColors();  // Send stuff in case the microcontroller is waiting to hear from you

}

void sendColors(){

  port.write(r);
  port.write(g);
  port.write(b); 
  //println("R" + r+ " G" + g + " B" + b);

}

void draw() {

  for(int i=0; i<width; i++) {
  for(int j=0; j<height; j++) {
    stroke(0, i, j);
    point(i, j);
  }

}

  int thisPixel = get(xpos,ypos);
  r = int(red(thisPixel));
  g = int(green(thisPixel));
  b = int(blue(thisPixel));
  fill(255,255,255);
  ellipse(xpos,ypos,10,10);

}

void serialEvent(Serial port) {

  String input = port.readStringUntil(10);  //make sure you return (Ascii 13) at the end of your transmission
  if (input != null){
    print("Raw Input: " + input);
    String[] parts = input.split(",");  //this will only work if you put commas (Ascii 44) between things in your transmission
    if (parts.length > 2){ //make sure it is a full valid message
      //turn them from ASCII into numbers
      int xtilt = int(parts[0]);
      int ytilt = int(parts[1]);
      if (xtilt > 500) {
        xpos = xpos + 1 ;// same as xpos++
      }
      else {
        xpos = xpos - 1 ;// same as xpos--
      }
      xpos = min(xpos,width);
      xpos = max(xpos,0);
      if (ytilt > 500) {
        ypos = ypos + 1 ;// same as ypos++
      }
      else {
        ypos = ypos - 1 ;// same as ypos--
      }
      ypos = min(ypos,width);
      ypos = max(ypos,0);
      println("Positionx:" + xpos + " y:" + ypos );
      sendColors();
    }
  }

}

2 analog, 1 switch and a servo

ARDUINO

int heat = 65; int light = 65; int onOff = 0;

void setup() {

  beginSerial(9600);
  pinMode(4, INPUT); 
  pinMode(2, OUTPUT); 

}

void loop() {

  if (Serial.available() > 0){  //only send if you have hear back
    int input = Serial.read();
    input = map(input,0,255,500,2500);    // convert the analog value
    // to a range between minPulse
    digitalWrite(2, HIGH);   // Turn the motor on
    delayMicroseconds(input);       // Length of the pulse sets the motor position
    digitalWrite(2, LOW);    // Turn the motor off


    heat  = analogRead(5);
    light  = analogRead(0);
    onOff = digitalRead(4);

    Serial.print(heat,DEC);
    Serial.print(44, BYTE);
    Serial.print(light,DEC);
    Serial.print(44, BYTE);
    Serial.print(onOff,DEC);
    Serial.print(44, BYTE);

    Serial.print(10, BYTE);  //send a return
    delay(20);  //you might use this instead of if available
  }

}

PROCESSING import processing.serial.*;

float bgColor; // Background color

Serial port; // The serial port float xpos; // position of the ball int shape;

void setup() {

  size(256, 256);  // Stage size
  noStroke();      // No border on the next thing drawn
  ellipseMode(CENTER);
  rectMode(CENTER);

  // Print a list of the serial ports, for debugging purposes to find out what your ports are called:
  println(Serial.list());
  //port = new Serial(this, Serial.list()[0], 9600);  //you can pull the name out of the list
  port = new Serial(this, "COM30", 9600);  //or you can just specify it
  port.write(65);    // Send a capital A in case the microcontroller is waiting to hear from you
  // println("OKAY LET'S GO");

}

void draw() {

  background(bgColor);
  fill(255,0,0);
  // Draw the shape
  if (shape == 0){
    ellipse(xpos, height/2, 20, 20);
  }
  else{
    rect(xpos, height/2, 20, 20);
  }

}

void serialEvent(Serial port) {

  String input = port.readStringUntil(10);  //make sure you return (Ascii 13) at the end of your transmission
  if (input != null){
    println("Raw Input: " + input);
    String[] parts = input.split(",");  //this will only work if you put commas (Ascii 44) between things in your transmission
    if (parts.length >= 3){


      bgColor =  int(parts[0]);
      bgColor = map(bgColor,500,1000,0,255);  

      xpos = int(parts[1]);
      xpos = map(xpos,500,580,0,width);  //400 and 625 were arrived at emperically by looking at readings from the sensor

      shape = int(parts[2]);

      float mouseDistanceAcross = map(mouseX,0,width,0,255);
      port.write(int(mouseDistanceAcross)); //in this example you might use the mouse distance across to control the panning of a servo motor
    }
  }

}

September 30, 2009, at 10:14 AM by tl881 -
Changed line 41 from:
  1. Tianwei Liu
to:
  1. Tianwei Liu
September 24, 2009, at 10:14 AM by dbo3 -
Added lines 72-74:

Tom's Greatest Hits

September 23, 2009, at 01:08 PM by dbo3 -
Changed lines 72-76 from:
to:
  if (input > biggestNumberIEverSaw){
    biggestNumberIEverSaw = input;
  }
  input = map(input, 800,biggestNumberIEverSaw,0,255);
September 23, 2009, at 10:49 AM by dbo3 -
Deleted line 31:
  1. Katherine Thomson" <ket262@nyu.edu>
September 20, 2009, at 10:56 AM by cqn200 -
Changed line 26 from:
  1. Christine Nguyen" <cqn200@nyu.edu>
to:
  1. Christine Nguyen" <cqn200@nyu.edu>
September 16, 2009, at 04:31 PM by tl881 -
Changed line 42 from:
  1. Tianwei Liu" <tl881@nyu.edu>
to:
  1. Tianwei Liu
September 16, 2009, at 03:37 PM by gab305 -
Changed line 28 from:
  1. Greg Borenstein
to:
  1. Greg Borenstein
September 16, 2009, at 11:12 AM by jd1783 -
Changed line 31 from:
  1. Jenine Durland" <jd1783@nyu.edu>
to:
  1. Jenine Durland" <jd1783@nyu.edu>
September 16, 2009, at 09:13 AM by swf220 -
September 16, 2009, at 09:13 AM by swf220 -
Changed line 39 from:
  1. Sean Fitzgerald" <swf220@nyu.edu>
to:
  1. Sean Fitzgerald
September 16, 2009, at 07:24 AM by saa359 -
Changed line 40 from:
  1. Steve Aquillano"
to:
  1. Steve Aquillano
September 16, 2009, at 07:24 AM by saa359 -
Changed line 40 from:
  1. Steve Aquillano" <saa359@nyu.edu>
to:
  1. Steve Aquillano"
September 16, 2009, at 06:47 AM by hn271 -
Changed line 29 from:
  1. Hana Newman" <hn271@nyu.edu>
to:
  1. Hana Newman
September 15, 2009, at 11:59 PM by mt1446 -
Changed line 35 from:
  1. Michelle Temple" <mt1446@nyu.edu>
to:
  1. Michelle Temple
September 15, 2009, at 10:33 PM by sn964 -
Changed line 41 from:
  1. Susan Ngo
to:
  1. Susan Ngo
September 15, 2009, at 01:06 PM by ic525 -
Changed line 30 from:
  1. Ian Cleary" <ic525@nyu.edu>
to:
  1. Ian Cleary" <ic525@nyu.edu>
September 15, 2009, at 01:06 PM by ic525 -
Changed line 30 from:
  1. Ian Cleary" <ic525@nyu.edu>
to:
  1. Ian Cleary" <ic525@nyu.edu>
September 14, 2009, at 06:45 PM by mk3321 -
Changed lines 43-44 from:
to:
  1. Mike Knuepfel" <mk3321@nyu.edu>
September 14, 2009, at 01:15 AM by pl874 -
Changed line 37 from:
  1. Peiyu Liu" <pl874@nyu.edu>
to:
  1. Peiyu Liu" <pl874@nyu.edu>
September 14, 2009, at 12:19 AM by mfc312 -
Changed line 34 from:
  1. Melissa Clarke" <mfc312@nyu.edu>
to:
  1. Melissa Clarke" <mfc312@nyu.edu>
September 12, 2009, at 10:38 PM by ph753 -
Changed line 38 from:
  1. Peter Holzkorn" <ph753@nyu.edu>
to:
  1. Peter Holzkorn
September 12, 2009, at 07:34 PM by nek243 -
September 12, 2009, at 07:12 PM by nek243 -
September 12, 2009, at 07:12 PM by nek243 -
Changed line 36 from:
  1. Noah King
to:
  1. Noah King
September 12, 2009, at 02:03 PM by mmc459 -
Changed line 33 from:
  1. [[http://itp.nyu.edu/~mmc459/error/ {[(Melanie Clemmons)]}
to:
  1. Melanie Clemmons
September 12, 2009, at 02:02 PM by mmc459 -
Changed line 33 from:
  1. Melanie Clemmons" <mmc459@nyu.edu>
to:
  1. [[http://itp.nyu.edu/~mmc459/error/ {[(Melanie Clemmons)]}
September 11, 2009, at 04:59 PM by sn964 -
Changed line 41 from:
  1. Susan Ngo"
to:
  1. Susan Ngo
September 11, 2009, at 04:59 PM by sn964 -
Changed line 41 from:
  1. Susan Ngo" <sn964@nyu.edu>
to:
  1. Susan Ngo"
September 11, 2009, at 10:08 AM by aw1320 -
Changed line 25 from:
  1. Ania Wagner" <hi.aniawagner@gmail.com>
to:
  1. Ania Wagner" <hi.aniawagner@gmail.com>
September 11, 2009, at 07:14 AM by nek243 -
September 11, 2009, at 07:13 AM by nek243 -
Changed line 36 from:
  1. Noah King" <digitalnoah@gmail.com>
to:
  1. Noah King
September 11, 2009, at 12:07 AM by aw1320 -
Changed line 25 from:
  1. Ania Wagner" <aw1320@nyu.edu>
to:
  1. Ania Wagner" <hi.aniawagner@gmail.com>
September 10, 2009, at 08:31 PM by mfc312 -
Changed line 34 from:
  1. Melissa Clarke" <mfc312@nyu.edu>
to:
  1. Melissa Clarke" <mfc312@nyu.edu>
September 10, 2009, at 06:03 PM by nek243 -
Changed line 36 from:
  1. Noah King" <digitalnoah@gmail.com>
to:
  1. Noah King" <digitalnoah@gmail.com>
September 10, 2009, at 04:05 PM by cqn200 -
Changed line 26 from:
  1. Christine Nguyen" <cqn200@nyu.edu>
to:
  1. Christine Nguyen" <cqn200@nyu.edu>
September 10, 2009, at 12:39 PM by gab305 -
Changed line 28 from:
  1. Gregory Borenstein" <gab305@nyu.edu>
to:
  1. Greg Borenstein
September 10, 2009, at 12:26 PM by dp1244 -
Changed line 27 from:
  1. David Phillips" <dp1244@nyu.edu>
to:
  1. David Phillips" <dp1244@nyu.edu>
September 10, 2009, at 12:06 PM by dp1244 -
Changed line 27 from:
  1. David Phillips" <dp1244@nyu.edu>
to:
  1. David Phillips" <dp1244@nyu.edu>
September 10, 2009, at 07:21 AM by nek243 -
Changed line 36 from:
  1. Noah King" <nek243@nyu.edu>
to:
  1. Noah King" <digitalnoah@gmail.com>
September 09, 2009, at 03:12 PM by jd1361 -
Changed lines 90-91 from:

test

to:
September 09, 2009, at 03:12 PM by jd1361 -
Changed lines 90-91 from:
to:

test

September 09, 2009, at 02:05 PM by dbo3 -
September 08, 2009, at 10:33 AM by dbo3 -
Changed lines 24-42 from:
to:
Changed lines 48-49 from:
  • Resistor Codes
to:
  • Blinky From Class
void setup()
{
  pinMode(2, OUTPUT);      // sets the digital pin as output
  pinMode(3, INPUT);
}

void loop()
{
  if (digitalRead(3)){
    digitalWrite(2, HIGH);   // sets the LED on
    delay(1000);                  // waits for a second
    digitalWrite(2, LOW);    // sets the LED off
    delay(1000);                  // waits for a second
  }
}
  • Resistor Codes
September 08, 2009, at 10:32 AM by dbo3 -
Changed lines 66-67 from:
to:
  • Resistor Codes
September 08, 2009, at 10:32 AM by dbo3 -
September 08, 2009, at 09:59 AM by dbo3 -
Changed lines 14-19 from:
to:

Syllabus
Lab Assignments
Tom Igoe's Physical Computing Site
Tom Igoe's Code and Resources Blog
ITP Sensor Workshop Wiki

September 08, 2009, at 09:58 AM by dbo3 -
Changed lines 13-14 from:
to:

Links

September 08, 2009, at 09:55 AM by dbo3 -
Added lines 19-20:
Deleted line 21:
Added line 24:
Deleted lines 25-26:
Changed lines 38-56 from:
to:
  1. Ania Wagner" <aw1320@nyu.edu>
  2. Christine Nguyen" <cqn200@nyu.edu>
  3. David Phillips" <dp1244@nyu.edu>
  4. Gregory Borenstein" <gab305@nyu.edu>
  5. Hana Newman" <hn271@nyu.edu>
  6. Ian Cleary" <ic525@nyu.edu>
  7. Jenine Durland" <jd1783@nyu.edu>
  8. Katherine Thomson" <ket262@nyu.edu>
  9. Melanie Clemmons" <mmc459@nyu.edu>
  10. Melissa Clarke" <mfc312@nyu.edu>
  11. Michelle Temple" <mt1446@nyu.edu>
  12. Noah King" <nek243@nyu.edu>
  13. Peiyu Liu" <pl874@nyu.edu>
  14. Peter Holzkorn" <ph753@nyu.edu>
  15. Sean Fitzgerald" <swf220@nyu.edu>
  16. Steve Aquillano" <saa359@nyu.edu>
  17. Susan Ngo" <sn964@nyu.edu>
  18. Tianwei Liu" <tl881@nyu.edu>
August 26, 2009, at 09:59 AM by dbo3 -
Changed lines 1-3 from:

Intro to Physical Computing (Fall 2008)

to:

Intro to Physical Computing (Fall 2009)

August 26, 2009, at 09:59 AM by dbo3 -
Added lines 1-65:

Intro to Physical Computing (Fall 2008)

  • Wednesday 12:30 p.m. – 3:00 p.m.
  • Dan's Office Hours: https://itp.nyu.edu/dano/hours
  • Dan's Email: dan.osullivan@nyu.edu

syllabus - Labs

Laptops

Laptops are very useful tools, but they are also very effective instruments of distraction. Everyone benefits if we all pay attention. I'll do my best to keep the class interesting, I hope you'll join me in this pursuit. You are welcome to use your laptop in class when I am speaking, or when it is relevant to the classwork being presented. However, during discussions and when your fellow students are talking, please be respectful of everyone's time and close the lid. If necessary, I'll remind of this, but even better would be if everyone does so naturally.

Journals

add a link to your pcomp journals below with your name:

Weekly Links

Week 1:

Week 2:

Week 3:

Week 4

Week 5

Week 6

Week 7

Week 8

Week 9

Week 10

Week 11

Week 12

  Edit | View | History | Print | Recent Changes | Search Page last modified on November 13, 2009, at 11:55 AM