As computing becomes more ubiquitous in our objects, designers need to be more aware of how to design meaningful interactions into electronically enhanced objects. At the University of Washington, a class of junior Interaction Design majors is exploring this question. These pages chronicle their efforts.

Saturday, April 27, 2013

Fading LED with Photoresistor : Kristina & Karin


Fading LED with Photoresistor

Kristina & Karin 


  */

int sensorPin = 0;   // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor
int setPoint = 255; //trigger value 
int ledPin = 13; 



void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);  
  pinMode (sensorPin, INPUT); 
  Serial.begin (255); //setup serial
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin); 
  Serial.println (sensorValue);   
  
  if (sensorValue < setPoint) {
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);  
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);  
  }
else {  
  // turn the ledPin off:        
  digitalWrite(ledPin, LOW);   
}
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);                  
}

No comments:

Post a Comment