(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


Scott Fitzgerald Fall 12

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

Contact:

Class List:

Additional links of interest

Supplies

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

Notes from Class

  • Week1

simple switch code from class

void setup() {

  // initialize the pin as an output.
  pinMode(2, OUTPUT);   
  // initialize the pin as an input.
  pinMode(3,INPUT);  

}

void loop() {

  if(digitalRead(3)==HIGH){  //if the switch is pressed
      digitalWrite(2, HIGH);   // set the LED on
  }else{                      //if it is not pressed
     digitalWrite(2, LOW);   // set the LED off 
  }

}

  • Week2
  • Week3
Purveyors of fine electronic goods :
  • Week4

Tom's taxonomy of Pcomp projects

  • Week5

mentioned in class
this to that
the old flying pig mechanisms page
Dustyn Robert's Making Things Move site

  • Week6
// constants to hold the output pin numbers:
const int redPin = 9;
const int greenPin = 10;
const int yellowPin = 11;

int currentPin = 0; // current pin to be faded
int brightness = 0; // current brightness level

void setup() {
  // initiate serial communication:
  Serial.begin(9600);

  // a for loop can simplify pin assignments
 for(int x=9;x<12;x++){
  pinMode(x, OUTPUT);
 }
}
void loop() {
  // if there's any serial data in the buffer, read a byte:
  if (Serial.available() > 0) {
    int inByte = Serial.read(); 

    // respond to the values 'r', 'g', 'y', or '0' throigh '9'.
    // you don't care about any other value:
    if (inByte == 'r') {
      currentPin = redPin; 
    }
    if (inByte == 'g') {
      currentPin = greenPin; 
    }
    if (inByte == 'y') {
      currentPin = yellowPin; 
    } 

    if (inByte >= '0' && inByte <= '9') {
      // map the incoming byte value to the range of the analogRead() command:
      brightness = map(inByte, '0', '9', 0, 255);  
      // set the current pin to the current brightness:
      analogWrite(currentPin, brightness);    
    } 
  }
}
  Edit | View | History | Print | Recent Changes | Search Page last modified on August 21, 2012, at 04:39 PM