Intro to Physical Computing Syllabus

Research & Learning

Other Class pages

Shop Admin

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


First Week

Spring 2009 home

  • Homer Simpson's 4 great inventions. What not to do for this class. In particular, the "Everything's ok alarm"
  • Tom's illustration of how power runs in a breadboard
  • While it may seem premature to think about project enclosures, it's never too early to consider what will house your electronics. this great flickr photoset has some inexpensive yet quality examples.
  • the resistor color code identifier dashboard widget mentioned in class, resistulator. there are several websites that do this too.

Code from class

  • Digital Out (two LEDs, one on pin 5, one on pin 6).. Woah! Crazy!
//first, let's name the pins, so we can refer to them later by name
#define LEDPin0 5
#define LEDPin1 6

//setup is where we initialize things
void setup(){

  //here we are declaring  LEDPin0 & LEDPin1 as outputs
  pinMode(LEDPin0, OUTPUT);
  pinMode(LEDPin1, OUTPUT);
}


//loop is your main program, it does this over and over and over again
void loop(){

  //Turn one led on, and turn the other off
  digitalWrite(LEDPin0, HIGH);
  digitalWrite(LEDPin1, LOW);

  //wait a moment, or 250 milliseconds (1/4 of a second)
  delay(250);

  //Turn one led off, and turn the other on
  digitalWrite(LEDPin0, LOW);
  digitalWrite(LEDPin1, HIGH);

  //wait again before repeating
  delay(250);

}
  • Digital In and Out (Switch on pin 2, LED on pin 5)
//first, let's name the pins, so we can refer to them later by name
#define LEDPin 5
#define SwitchPin 2

//setup is where we initialize things
void setup(){

  //here we are declaring the LEDPin as an output (it will light up)
  pinMode(LEDPin, OUTPUT);

  //here we declare the SwitchPin as an input (it listens for a digital on/off) 
  pinMode(SwitchPin, INPUT);

}


//loop is your main program, it does this over and over and over again
void loop(){

  //an if statement is a conditional, saying "if this thing is 
  //[true, greater than, not equal to...], then do this other thing"

  //in English, we would say "read the value on the SwitchPin.  If the value is equal to 1...  
  if(digitalRead(SwitchPin)==1) {

    //turn the LEDPin on
    digitalWrite(LEDPin, HIGH);
  }
  else{ //if there is a different condition (ex. the SwitchPin == 0), do this instead

    //turn the LED off
    digitalWrite(LEDPin, LOW);
  }
}
  Edit | View | History | Print | Recent Changes | Search Page last modified on January 28, 2009, at 05:38 PM