(edit sidebar)
Intro to Physical Computing Syllabus

Research & Learning

Other Class pages

Shop Admin

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


Benedetta F 2011-1

Syllabus Main? Labs & tutorials Books and Readings Parts & Supplies ClassPages

Info

What: Intro to Physical Computing H79.2301.2
When: Mondays 12.30 - 3.00pm (Monday Class Dates)
Where: NYU Tisch Building, 4th floor, Room 406
Who: Benedetta Piantella

Contact

Best way to reach me is via email at: bp432@nyu.edu
To set up an appointment within office hours or outside, please email me.
Office Hours: Mondays 3.30 - 5.30pm

Grading

Participation & Attendance: 40%
Production Assignments: 40%
Journal: 20%

Supplies

See http://itp.nyu.edu/physcomp/Intro/Supplies

Useful Links

http://www.arduino.cc - Arduino website. Check out the Getting Started and the Reference pages
http://tigoe.net/pcomp/ - Tom Igoe's Physical Computing site
http://www.tigoe.net/pcomp/code/ - Tom's Code, Circuits & Construction blog
http://itp.nyu.edu/physcomp/sensors/ - ITP Sensor Workshop wiki from another class at ITP
http://itp.nyu.edu/mechanisms/ - Dustyn Roberts' class on mechanisms, very useful for when we do motors
http://www.flying-pig.co.uk/ - Website about movement and good explanation on how to recreate mechanisms

Cool Reference Books

Physical Computing: Sensing and Controlling the Physical World with Computers
Getting Started with Arduino
Make: Electronics
Getting Started in Electronics
Making Things Move
Practical Electronics For Inventors
Energy There are no electrons; Electronics for earthlings
Fashioning Technology: A DIY Intro to Smart Crafting

Class Blogs

Please press "Edit" at the bottom of this page, login and enter the url to your blog (if you are new to wiki formatting just follow the pattern)

  1. Annelie Berner
  2. Dollee Bhatia
  3. James Borda
  4. Hsiao-Wen Chou
  5. Ioni Gkliati
  6. Sae-Wook Huh
  7. Mark Kleback
  8. Lisa (Yelizaveta) Lokshina
  9. Bruna Silva
  10. Chisom Onuoha
  11. Kojo Opuni
  12. Robin Reid
  13. Alex Samoilescu
  14. Rose Schlossberg
  15. Ryan Viglizzo
  16. Phil Groman
  17. Saki Hayashi

Notes from Class

Week1 - September 12th

Resistors
Widget for Mac or App for iPhone and iPod: http://www.apple.com/downloads/dashboard/calculate_convert/resistulator.html
Online Graphical Calculator: http://www.pcboard.ca/technical_notes/resistor/

Breadboards
This illustration from ITP alum Jody Culkin's arduino comic book might be helpful:
http://boingboing.net/2011/09/11/comic-book-introduction-to-arduino.html

Some Helpful Online Components Stores
http://www.sparkfun.com
http://www.adafruit.com
http://www.digikey.com
http://www.jameco.com

Week2 - September 19th

Week3 - September 26th

Useful links from class:

Lion Tracking Project (mentioned in class because of all the animal tracking fantasy devices!):
http://home.groundlab.cc/lioncollars.html

The actual conservancy theory behind the project:
http://lionguardians.wildlifedirect.org/
http://www.lionconservation.org/

From our Sensor Workshop class, here is a cool list of sensors and reports people have used:
http://itp.nyu.edu/physcomp/sensors/Reports/Reports

Schematic Symbols (I will cover most schematic symbols of thing we use in class, but the Internetz is a great place to look them up):
http://www.kpsec.freeuk.com/symbol.htm
http://library.thinkquest.org/10784/circuit_symbols.html
Or books by Forrest Mims are a good resource too: http://www.forrestmims.org/

Fritzing (for drawing Arduino circuits and schematics)
http://fritzing.org/

Some resources on accelerometers (we will look at this sensor in class in a few weeks)
http://itp.nyu.edu/physcomp/sensors/Reports/Reports
(look at the section marked as Tilt, Acceleration, Position, and Orientation sensors)
http://www.dimensionengineering.com/accelerometers.htm
http://www2.usfirst.org/2005comp/Manuals/Acceler1.pdf
(a downloadable guide from Texas Instruments)
more links coming soon...

Arduino and Sensors or other things:
http://www.arduino.cc/playground/
(this is the Arduino playground, where people have contributed with code and libraries to interface different things with Arduino)

Week4 - October 3rd

Code from class:

Analog Input and Analog Output: Demonstrates analog input by reading an analog sensor on analog pin 0 and dimming a light emitting diode(LED), using PWM functionality of pin 3.

//declare our FSR pin int sensorPin = A0;

//declare our FSR value int sensorValue = 0;

//declare LED pin int ledPin = 3;

void setup(){

  //init Serial monitor
  Serial.begin(9600);

  //declare our output
  pinMode(ledPin, OUTPUT);

}

void loop(){

  sensorValue = analogRead(sensorPin); //read our FSR value
 // we remember that the range of our FSR 0 - 980

 int brightness = map(sensorValue, 0, 980, 0, 255); //remap the sensor value to a range from 0 to 255

 analogWrite(ledPin, brightness); //PWM led pin 0 - 255 resolution

 Serial.println(sensorValue);
 delay (10);

}

Analog Input and Analog Output: Demonstrates analog input by reading an analog sensor on analog pin 0 and controlling a servo motor on pin 9 using the Servo library.

#include <Servo.h> // include the servo library

Servo servoMotor; // creates an instance of the servo object to control a servo int servoPin = 9; // Control pin for servo motor

int sensorPin = A0; // Pin our FSR is plugged into int sensorValue = 0; // initialize value at 0

void setup() {

  Serial.begin(9600);       // initialize serial communications
  servoMotor.attach(servoPin);  // attaches the servo on pin 3 to the servo object

}

void loop() {

  sensorValue = analogRead(sensorPin); // read the analog input
  Serial.println(sensorValue);      // print it
  delay(5);

  // if your sensor's range is less than 0 to 1023, you'll need to
  // modify the map() function to use the values you discovered:
  int servoAngle = map(sensorValue, 0, 975, 0, 179);

   //  Serial.println(servoAngle);     
   //  delay(5);

  // move the servo using the angle from the sensor:
  servoMotor.write(servoAngle);                  

}

Week5 - October 17th

Media Controller Groups:

  1. Rose, Ryan and Mark;
  2. Annelie, Mimi and Bruna;
  3. Lisa, Dollee, Robin, Tiffany;
  4. Alex, Phil, James;
  5. Sae, Ioni, Kojo.

Week6 - October 24th

Week7 - October 31st

Code from class:

Different Data Formats:

int xPin = A0; // the analog pin our accelerometer is plugged into
int xValue = 0; // the value from the x Pin

void setup(){

  Serial.begin(9600);
  Serial.println("hello world");

}

void loop (){

  xValue = analogRead(xPin);
   Serial.print("x = ");        // just some nice formatting
   Serial.println(xValue);      // print the ASCII encoded decimal value 

   // print in many formats:
   Serial.write(xValue);        // Print the raw binary value
   Serial.print('\t');          // print a tab
   Serial.print(xValue, BIN);   // print the ASCII encoded binary value
   Serial.print('\t');          // print a tab
   Serial.print(xValue, DEC);   // print the ASCII encoded decimal value (same as above)
   Serial.print('\t');          // print a tab
   Serial.print(xValue, HEX);   // print the ASCII encoded hexadecimal value
   Serial.print('\t');          // print a tab
   Serial.println(xValue, OCT); // print the ASCII encoded octal value

   delay(300);                  // just so that you can read them slowly
 }

Punctuation Method - Virtual Color Mixer:

int xPin = A0;
int yPin = A1;
int zPin = A2;
//int switchPin = 2;

int xValue = 0;
int yValue = 0;
int zValue = 0;
//int button = 0;

void setup(){

 // pinMode(switchPin, INPUT);

  Serial.begin(9600);
  //Serial.println("hello world");

}

void loop (){

  xValue = analogRead(xPin);
  Serial.print(xValue);
  Serial.print(",");

  yValue = analogRead(yPin);
  Serial.print(yValue);
  Serial.print(",");

  zValue = analogRead(zPin);
  Serial.println(zValue);


 // button = digitalRead(switchPin);
 // Serial.println(button);

}

Processing code:

// Processing code for this example
// This example code is in the public domain.

import processing.serial.*;

 float redValue = 0;        // red value
 float greenValue = 0;      // green value
 float blueValue = 0;       // blue value

 Serial myPort;

 void setup() {
 size(200, 200);

 // 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, so I open Serial.list()[0].
 // Open whatever port is the one you're using.
 myPort = new Serial(this, Serial.list()[0], 9600);
 // don't generate a serialEvent() unless you get a newline character:
 myPort.bufferUntil('\n');
 }

 void draw() {
 // set the background color with the color values:
 background(redValue, greenValue, blueValue);
 }

 void serialEvent(Serial myPort) { 
 // get the ASCII string:
 String inString = myPort.readStringUntil('\n');


 if (inString != null) {
 // trim off any whitespace:
 inString = trim(inString);
 // split the string on the commas and convert the 
 // resulting substrings into an integer array:
 float[] colors = float(split(inString, ","));
 // if the array has at least three elements, you know
 // you got the whole thing.  Put the numbers in the
 // color variables:
 if (colors.length >=3) {
 // map them to the range 0-255:
 redValue = map(colors[0], 0, 900, 0, 255);
 greenValue = map(colors[1], 0, 900, 0, 255);
 blueValue = map(colors[2], 0, 900, 0, 255);
 }
 }

 }


Handshaking/Call and Response Method in ASCII:

int firstSensor = 0; // first analog sensor
int secondSensor = 0; // second analog sensor
int thirdSensor = 0; // digital sensor
int inByte = 0; // incoming serial byte

void setup() {

  // start serial port at 9600 bps:
  Serial.begin(9600);
  pinMode(2, INPUT);   // digital sensor is on digital pin 2
  establishContact();  // send a byte to establish contact until receiver responds 

}

void loop() {

  // if we get a valid byte, read analog ins:
  if (Serial.available() > 0) {
    // get incoming byte:
    inByte = Serial.read();
    // read first analog input, divide by 4 to make the range 0-255:
    firstSensor = analogRead(A0);
    // delay 10ms to let the ADC recover:
    delay(10);
    // read second analog input, divide by 4 to make the range 0-255:
    secondSensor = analogRead(A1);
    // read  switch, map it to 0 or 255L
    thirdSensor = map(digitalRead(2), 0, 1, 0, 255);  
    // send sensor values:
    Serial.print(firstSensor);
    Serial.print(",");
    Serial.print(secondSensor);
    Serial.print(",");
    Serial.println(thirdSensor);               
  }

}

void establishContact() {

  while (Serial.available() <= 0) {
    Serial.println("0,0,0");   // send an initial string
    delay(30);
  }

}

Processing code:

// Processing code to run with this example:

// This example code is in the public domain.

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());

  // 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');

  // draw with smooth edges:
  smooth();

}

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:
    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], 0,1023,0,width);
      ypos = map(sensors[1], 0,1023,0,height);
      fgcolor = sensors[2];
    }
    // send a byte to ask for more data:
    myPort.write("A");
  }

Serial Communication to make the Arduino manipulate physical things - Physical Pixel:

int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into

void setup() {

  // initialize serial communication:
  Serial.begin(9600);
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);

}

void loop() {

  // see if there's incoming serial data:
  if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it's a capital H (ASCII 72), turn on the LED:
    if (incomingByte == 'H') {
      digitalWrite(ledPin, HIGH);
    } 
    // if it's an L (ASCII 76) turn off the LED:
    if (incomingByte == 'L') {
      digitalWrite(ledPin, LOW);
    }
  }

}

Processing code:

import processing.serial.*;

float boxX;
float boxY;
int boxSize = 20;
boolean mouseOverBox = false;

Serial port;

void setup() {

 size(200, 200);
 boxX = width/2.0;
 boxY = height/2.0;
 rectMode(RADIUS); 

 // List all the available serial ports in the output pane. 
 // You will need to choose the port that the Arduino board is 
 // connected to from this list. The first port in the list is 
 // port #0 and the third port in the list is port #2. 
 println(Serial.list()); 

 // Open the port that the Arduino board is connected to (in this case #0) 
 // Make sure to open the port at the same speed Arduino is using (9600bps) 
 port = new Serial(this, Serial.list()[0], 9600); 

 }

 void draw() 
 { 
 background(0);

 // Test if the cursor is over the box 
 if (mouseX > boxX-boxSize && mouseX < boxX+boxSize && 
 mouseY > boxY-boxSize && mouseY < boxY+boxSize) {
 mouseOverBox = true;  
 // draw a line around the box and change its color:
 stroke(255); 
 fill(153);
 // send an 'H' to indicate mouse is over square:
 port.write('H');       
 } 
 else {
 // return the box to it's inactive state:
 stroke(153);
 fill(153);
 // send an 'L' to turn the LED off: 
 port.write('L');      
 mouseOverBox = false;
 }

 // Draw the box
 rect(boxX, boxY, boxSize, boxSize);
 }

Week8 - November 7th

XBee set up Lab

Plug in your XBee with PWR (3.3V), GND, TX and RX. You can use all sorts of USB to Serial converter for the XBees, I was using the simple FTDI breakout board from SparkFun. You program the XBees through CoolTerm or another Serial monitor program. 9600 baud rate, local echo and remember only CR as options. These are some of the basic commands to program both XBees to send to each other over the same Pan ID.


+++OK

ATMY
2222

ATID
811

ATDL
1111

ATDH
0

The other one would be programmed as such:

+++OK

ATMY
1111

ATID
811

ATDL
2222

ATDH
0

For reference +++ = Command Mode, ATCN = Data Mode

Week10 - November 21st

Controlling DC Motor Direction with HBridge

int motor1Pin = 3; // H-bridge leg 1 (pin 2, 1A)
int motor2Pin = 4; // H-bridge leg 2 (pin 7, 2A)
int enablePin = 9; // H-bridge enable pin


void setup() {

    Serial.begin(9600);

    // set all the other pins you're using as outputs:
    pinMode(motor1Pin, OUTPUT);
    pinMode(motor2Pin, OUTPUT);
    pinMode(enablePin, OUTPUT);

    // set enablePin high so that motor can turn on:
    digitalWrite(enablePin, HIGH); 

}

void loop() {

    // Turn on one direction:

      digitalWrite(motor1Pin, LOW);   // set leg 1 of the H-bridge low
      digitalWrite(motor2Pin, HIGH);  // set leg 2 of the H-bridge high

      delay (2000);    

      digitalWrite(motor1Pin, HIGH);  // set leg 1 of the H-bridge high
      digitalWrite(motor2Pin, LOW);   // set leg 2 of the H-bridge low

      delay (2000);    

}

Controlling DC Motor Direction & Speed with HBridge

int motor1Pin = 3; // H-bridge leg 1 (pin 2, 1A)
int motor2Pin = 4; // H-bridge leg 2 (pin 7, 2A)
int enablePin = 9; // H-bridge enable pin


void setup() {

    Serial.begin(9600);

    // set all the other pins you're using as outputs:
    pinMode(motor1Pin, OUTPUT);
    pinMode(motor2Pin, OUTPUT);
    pinMode(enablePin, OUTPUT);

    // set enablePin high so that motor can turn on:
    digitalWrite(enablePin, HIGH); 

}

void loop() {

    // Turn on one direction:

      digitalWrite(motor1Pin, LOW);   // set leg 1 of the H-bridge low
      digitalWrite(motor2Pin, HIGH);  // set leg 2 of the H-bridge high

      for (int motorSpeed = 0; motorSpeed < 255; motorSpeed++){
      analogWrite(enablePin, motorSpeed);
      delay(4);
      }

      delay (2000);    

      digitalWrite(motor1Pin, HIGH);  // set leg 1 of the H-bridge high
      digitalWrite(motor2Pin, LOW);   // set leg 2 of the H-bridge low

      for (int motorSpeed = 0; motorSpeed < 255; motorSpeed++){
        analogWrite(enablePin, motorSpeed);
        delay(4);
      }

      delay (2000);    

}

Controlling a Unipolar Stepper Motor with HBridge

#include <Stepper.h>


// change this to the number of steps on your motor
#define STEPS 1000


// create an instance of the stepper class
Stepper stepper(STEPS, 3, 4, 5, 6);


void setup() {

  Serial.begin(9600);
  Serial.println("Resetting");
  // set the speed of the motor to 30 RPMs
  //stepper.setSpeed(30);

}

void loop() {

  stepper.step(10);
  Serial.println("Stepping");
  delay(100);

}

Final Projects Groups and Ideas

  1. Mark + Sae = Interactive Bar
  2. James + Bruna = Synaesthesia
  3. Phil + Alex = Interactive Display
  4. Rose = Accelul8r
  5. Robin = Controlling Chants with Breath
  6. Dollee = Sensory Audio Enhancer
  7. Annelie = Weather Box
  8. Ryan = Unfinished Painting
  9. Ioni = Emotional Head
  10. Mimi = Walking Strangers
  11. Tiffany = Print your own music
  12. Kojo = Jewel Heist
  13. Lisa = Etch-a-Sketch

Week11 - November 28th

Patches from Luke's demo here!
Click on the link called Lukes_patches.zip to download the Max Patches from class.

Final Presentation Days & Groups:

December 12th

  1. Ryan
  2. Lisa
  3. Alex + Phil
  4. Rose
  5. Tiffany
  6. Mimi

December 14th

  1. Dollee
  2. Sae + Mark
  3. Ioni
  4. Bruna + James
  5. Annelie
  6. Kojo
  7. Robin

Office Hours Thursday 12/8:

  1. 2-2.30pm =
  2. 2.30-3pm = Tiffany
  3. 3-3.30pm = Mimi
  4. 3.30-4pm = Robin
  5. 4-4.30pm = Lisa
  6. 4.30-5pm = Phil
  7. 5-5.30pm = Annelie
  8. 5.30-6pm = James (let me know if the time is ok)
  Edit | View | History | Print | Recent Changes | Search Page last modified on September 09, 2013, at 04:52 PM