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.

Monday, April 29, 2013

Pressure Sensors & Amy's Ego...

Pressure Sensor:
Our sensor was a paper thin strip with a circle pad that was a pressure sensor. The harder you squeeze the brighter the bulb got, but it never turned all the way off upon release.
int sensorPin = A0;int ledPin = 9;int sensorValue = 0;
void setup(){ pinMode(ledPin, OUTPUT);}
void loop() { sensorValue = analogRead(sensorPin); sensorValue = sensorValue/3; analogWrite(ledPin, sensorValue); //delay();}



Analog In/Out Serial: "Amy is ____ Beautiful"
*/
// the pins used:
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
int count = 0;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
count = count + 1;
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
//Serial.print("sensor = " );
//Serial.print(sensorValue);
//Serial.print("\t output = ");
Serial.print("Amy is");
Serial.print(count);
Serial.println( "x beautiful");
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(2);
}

1 comment:

  1. Ashley, one way you could deal with the light not turning all the way off is to subtract whatever the baseline reading is (the value when you aren't pressing it) from the sensor variable before you write it to the light. that way, it will write (0) when you aren't pressing the sensor.

    ReplyDelete