Love Machine | JH5363

I felt inspired by hands after our hand free switches and decided to make a love machine that required the two potential lovers connect with their hands. I had trouble thinking of way to activate a switch upon their hands connecting so I instead used capacitive sensing to measure when the two people at placed their hand on the machine. Also in order to give the users some signifiers I added a hand-print outline to both sides and led’s that light when each individual hand is sensed.

Materials:

  • cardboard box (17 cm x 25 cm x 8 cm)
  • Arduino Uno
  • 2 single-color LEDs
  • 1 RGB LED
  • resistors (2 x 100K ohm, 5 x 220 ohm)
  • tin foil
  • wires
  • breadboard

Process:

I started with getting the capacitive sensing to work. Essentially capacitive sensing allows us to read whether or not physical contact has been made to skin. It can even sense through other objects if a large enough resistor is used. I used the Arduino CapacitiveSensing library. This is the circuit diagram provided in the library’s documentation:

Capacitive Sensing Circuit

Essentially two digital pins are needed to use capacitive sensing, but one send pin can be used for multiple receive pins. Also the resistor needs to be at least 10k ohms but ideally between 100K ohms and 50M ohms. The larger the resistance the more sensitive the sensing is. I also linked two LEDs to capacitive sensor to give a visual indication if they were being sensed. Sometimes one needs to make firm contact in order for the signal to be picked up.

The next thing I needed to wire up is the RGB led. It is pretty easy to do, just need three pins to control each of the Red, Green, and Blue LEDs as well as resistors between the anode and digital pin. And one final pin that goes to ground. Here is the circuit diagram for that:

RGB LED wiring

The final thing was putting all the components into the box. I poked holes for all the LED wires and just stuck wires out to connect to the palm of each hand. I designed it so that when the two users put their hands up it seems like they are putting their hands up against each others. I also made both hand prints right hands so that it was clear the machine is supposed to be used with two people instead of just one.

The LED stops on one of the 7 colors of the rainbow which indicates how good they would be together. Red being the best, violet the worst. I made a color coded scale on the top next to the RGB led in order to illustrate this.

The box is relatively self contained so there aren’t too many affordances here for the user. The only real option is place your hand where the hand print is. Once you place your hand an LED will light up giving indication that something had been activated. If they take their hand away the LED deactivates and its clear what caused it. When both hands are put up both LED’s start blinking rapidly and then stop at which point the RGB led cycles through colors until it finally picks one and blinks that color. A relatively simple yet self-explanatory device.

Code:

#include <CapacativeSensor.h>

CapacitiveSensor cs_2_3 = CapacitiveSensor(2,3); // 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, add wire, foil
CapacitiveSensor cs_2_4 = CapacitiveSensor(2,4);

int led1 = 8;
int led2 = 7;
int rPin = 11;
int gPin = 10;
int bPin = 9;

void decide(){
randomSeed(millis());
int x = random(7);
switch (x){
case 0:
flashColor(148, 0, 211);
break;
case 1:
flashColor(75, 0, 130);
break;
case 2:
flashColor(0, 0, 255);
break;
case 3:
flashColor(0, 255, 0);
break;
case 4:
flashColor(255, 255, 0);
break;
case 5:
flashColor(255, 127, 0);
break;
case 6:
flashColor(255, 0 , 0);
break;

}

}

void flashHands(){
for(int i = 0; i<10; i++){
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
delay(200);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
delay(200);
}

}

void flashColor(int r, int g, int b){
for(int i = 0; i<6; i++){
analogWrite(rPin, r);
analogWrite(gPin, g);
analogWrite(bPin, b);
delay(700);
analogWrite(rPin, 0);
analogWrite(gPin, 0);
analogWrite(bPin, 0);
delay(200);
}
}

void setColor(int r, int g, int b){
analogWrite(rPin, r);
analogWrite(gPin, g);
analogWrite(bPin, b);
}

void rainbow(){
//wonderful code snippet borrowed from https://gist.github.com/jamesotron/766994

unsigned int rgbColour[3];

rgbColour[0] = 255;
rgbColour[1] = 0;
rgbColour[2] = 0;

// Choose the colours to increment and decrement.
for (int decColour = 0; decColour < 3; decColour += 1) {
int incColour = decColour == 2 ? 0 : decColour + 1;

// cross-fade the two colours.
for(int i = 0; i < 255; i += 1) {
  rgbColour[decColour] -= 1;
  rgbColour[incColour] += 1;

  setColor(rgbColour[0], rgbColour[1], rgbColour[2]);
  delay(5);
}

}

}

void setup()
{

cs_2_3.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 – just as an example
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(rPin, OUTPUT);
pinMode(gPin, OUTPUT);
pinMode(bPin, OUTPUT);
}

void loop()
{
long start = millis();
long total1 = cs_2_3.capacitiveSensor(30);
long total2 = cs_2_4.capacitiveSensor(30);

// Serial.println(total1);

Serial.print(total1);                  // print sensor output 1
Serial.print("\t");
Serial.println(total2);                  // print sensor output 2

if(total1 > 17){ 
  digitalWrite(led1, HIGH);
  }else{digitalWrite(led1, LOW);}

if(total2 > 17){ 
  digitalWrite(led2, HIGH);
  }else{digitalWrite(led2, LOW);}

if(total1 > 17 and total2 > 17){
  flashHands();
  rainbow();
  rainbow();
  decide(); //super secret love matching formula!!!!
  delay(5000);
  analogWrite(rPin, 0);
  analogWrite(gPin, 0);
  analogWrite(bPin, 0);
  }



delay(10);                             

}