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.

Thursday, April 26, 2012

Claire & Sheema: Pressure Sensor & LED

We used a pressure sensor to detect how hard someone is squeezing and then adjust the LED accordingly. If you don't squeeze too hard the LED turns on and says on until you let go. But if you squeeze harder, the LED will start blinking. 



LED will start blinking if squeeze even harder. 


// Exercise : Pressure Sensor and LED

int LED = 13; // LED connected to digital pin 13
int sensorPin = A0;
int sensorValue = 0;

void setup()
{
  pinMode(LED, OUTPUT); // sets the digitalpin as output
}

void loop()
{
  sensorValue = analogRead(sensorPin);
  if (sensorValue >100 && sensorValue <=600)
  {
    digitalWrite(LED, HIGH); // turns the LED on
  }
  else if (sensorValue >600)
  {
    digitalWrite(LED, HIGH); // turns the LED on
    delay(100); // waits for a second
    digitalWrite(LED, LOW); // turns the LED off
    delay(100); // waits for a second
  }
  else
  {
    digitalWrite(LED, LOW); // turns the LED off
  }
}


No comments:

Post a Comment