(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 F2011-THURS-1230

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

Contact:

Class List:

Additional links of interest

Class Rescheduling

As a reminder, our class on Thursday the 6th needs to be moved to a different date. I scheduled some work in Chicago before I knew I would be teaching Thursdays. The dates I was thinking are Monday Oct 3 9:30-12 or Tuesday October 4 12:30-3. Thank you all for your understanding and general wonderfulness. Please let me know what you think, and I can arrange it with Gordie.

Vote here : https://docs.google.com/document/d/1BqE5T5iF0X3tSuywa2yARMNa4PphdKTkAN4v9Di7Ro8/edit?hl=en_US

Supplies

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

Notes from Class

  • Week1
  • Week2
Code from class

//example to blink at a variable rate
//led on pin 2, pot on A0
int potVal=0;

void setup(){
}

void loop(){

 potVal=analogRead(A0); 

 digitalWrite(2, HIGH);
 delay(potVal);
  digitalWrite(2, LOW);
 delay(potVal); 
}

//Example for ranging our photocell
int potVal=0;
int mappedVal=0;

void setup(){
  Serial.begin(9600);
}


void loop(){

 potVal=analogRead(A0); 

//photocell low was about 240, high was about 810 
 mappedVal=map(potVal, 240, 810, 0, 1023);

  Serial.print("mapped Value : ");
  Serial.print(mappedVal);
    Serial.print("\t");
 Serial.print("Photocell value : ");
 Serial.println(potVal);
 delay(10);

}


//Example mapping to see what values mean to voltages
//each increment = about .049V

int potVal=0;
int mappedVal=0;

void setup(){
  Serial.begin(9600);
}

void loop(){  
 potVal=analogRead(A0); 

 mappedVal=map(potVal, 0, 1023, 0, 500);

  Serial.print("Voltage : ");
  Serial.print(mappedVal);
    Serial.print("\t");
  Serial.print("Arduino's value : ");
 Serial.println(potVal);
 delay(10);
}



  • Week3
Purveyors of fine electronic goods :
  • Week4

Tom's taxonomy of Pcomp projects

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

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);
  analogWrite(x, 255);
 }


}
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', 'b', or '0' through '9'.
    // you don't care about any other value:
    if (inByte == 'r') {
      currentPin = redPin; 
    }
    if (inByte == 'g') {
      currentPin = greenPin; 
    }
    if (inByte == 'b') {
      currentPin = bluePin; 
    } 

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