« Counting Daily Uses II | Main | Midterm Observation: Mastermind »

Love Meter

Assignment: Make a luv-o-meter with analog inputs. A luv-o-meter is a device that measures a person's potential to be a lover, and displays it on a graph of lights. Your luv-o-meter can measure any analog physical quantity that you want, providing you have a sensor for it. Make sure the display is clear, so the participant knows what it means, and make sure it is responsive.

For this assignment, I attached a flex sensor to a wire, supporting a target for the participant to aim at with a soft ball or toy bow and arrow. The more accurate the hit, the more the flex sensor bends, and the higher love rating for the participant (white=mild, yellow=medium, red=spicy).

Problems I encountered while working on this assignment related primarily to the delicacy of the flex sensor. I accidentally tore one of the pins off the sensor when installing it in the box, and had to duct tape it back together.

Breadboard & Arduino Setup

Arduino Code

int flexPin = 0;    // Analog input pin that the flex sensor is attached to
int flexValue = 0;   // value read from the pot
int lowLED = 3;    // low LED 
int mediumLED = 4; // medium LED
int highLED = 5; // high LED
boolean loveInput = false; // test whether someone has tried

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600); 
  
  pinMode(lowLED, OUTPUT);      // set the yellow LED low pin to be an output
  pinMode(mediumLED, OUTPUT);      // set the green LED medium pin to be an output
  pinMode(highLED, OUTPUT);      // set the red LED high pin to be an output
}

void loop() {
  Serial.println(flexValue);      // print the flex value back to the debugger pane
  // read the flex input:
  flexValue = analogRead(flexPin); // read the flex value
  if (flexValue <= 45) {
    digitalWrite(lowLED, HIGH);    // turn the low LED on
    digitalWrite(mediumLED, HIGH);    // turn the medium LED on
    digitalWrite(highLED, HIGH);    // turn the high LED on
    loveInput = true;
  }
  else if (flexValue <= 60) {
    digitalWrite(lowLED, HIGH);    // turn the low LED on
    digitalWrite(mediumLED, HIGH);    // turn the medium LED on
    digitalWrite(highLED, LOW);    // turn the high LED off
    loveInput = true;
  }
  else if (flexValue <= 72) {
    digitalWrite(lowLED, HIGH);    // turn the low LED on
    digitalWrite(mediumLED, LOW);    // turn the medium LED off
    digitalWrite(highLED, LOW);    // turn the high LED off
    loveInput = true;
  }
 else {
   digitalWrite(lowLED, LOW);    // turn the low LED off
   digitalWrite(mediumLED, LOW);    // turn the medium LED off
   digitalWrite(highLED, LOW);    // turn the high LED off
 }
 if (loveInput == true){
   delay(2000);
 }
}

TrackBack

TrackBack URL for this entry:
http://itp.nyu.edu/~km63/cgi-bin/mt/mt-tb.cgi/6

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)