Soft Touch.

Posted by | September 15, 2008 | ITP, Physical Computing | No Comments

Alright, so it’s time for Lab 3. Was gonna do it tomorrow but it was a Sunday night and I was bored. So~ here it is. Let’s skip the boring stuff and go straight to the Luv-O-Meter.

I took the basic concept of a squeeze handle love meter and changed it a bit. Anyone can go up to a meter and squeeze it. But, what if you had to squeeze it a different amount depending on another variable. So basically you have to match up the potentiometer w/ the pressure sensor. Like making love, and unlike your regular luv-o-meter… this requires some skill.

Here’s the video:

Harder than it looks. I had *plenty* of time to practice. And don’t even talk to me about trying to keep the light steady… ugh.

I wanted to call my meter “GUTS!!!”, but after playing around with it a bit, I realized “Soft Touch” fits it better. I also wanted to use 2 force sensors, but only had 1 on hand. That would have made this game really fun.


Also, here’s the Arduino code:

int potPin1 = 0;    // Pressure Sensor
int potPin2 = 1;    // Potentiometer

int potValue1 = 0;   // value read from the pot
int potValue2 = 0;
       
int led2 = 2;        // LEDs
int led3 = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;
int led7 = 7;
int led8 = 8;

void setup() {
  //set up led's as outputs
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);
  pinMode(led8, OUTPUT);
  
  // initialize serial communications at 9600 bps:
  Serial.begin(9600); 
}

void loop() {
  potValue1 = analogRead(potPin1); // read the pressure/pot values
  potValue2 = analogRead(potPin2);
  
  if(potValue1 < 25 || potValue2 < 25) {lightDown(2);}
  else {
    //if(potDiff(potValue1, potValue2) >= 300 ){lightDown(2);}
    if(potDiff(potValue1, potValue2) < 5)
      {lightUp(8);}
    else if(potDiff(potValue1, potValue2) < 26 ){lightDown(8); lightUp(7);}
    else if(potDiff(potValue1, potValue2) < 50 ){lightDown(7); lightUp(6);}
    else if(potDiff(potValue1, potValue2) < 100 ){lightDown(6); lightUp(5);}
    else if(potDiff(potValue1, potValue2) < 150 ){lightDown(5); lightUp(4);}
    else if(potDiff(potValue1, potValue2) < 200 ){lightDown(4); lightUp(3);}
    else if(potDiff(potValue1, potValue2) < 250 ){lightDown(3); lightUp(2);}
    else if(potDiff(potValue1, potValue2) < 300 ){lightDown(2);}
  }

  
  //Serial.println(potDiff(potValue1, potValue2));  //debugging
  delay(10);                     // wait 10 milliseconds before the next loop
}

/* Difference in numbers between pot and pressure sensors */
int potDiff(int x, int y)
{
  return abs(x-y);
}

/* Turn all the led on up to num */
void lightUp(int num)
{
  for(int i=2; i<=num; i++)
  {
    digitalWrite(i, HIGH);
  }
}

/* Turn all the led's off down to num */
void lightDown(int num)
{
  for( int i=8; i >= num; i--)
  {
    digitalWrite(i, LOW);
  }
}

Leave a Reply

Your email address will not be published.