Introduction: Mezuzah Kiss Sensor - Lane Tech

This year, I tried to become a better Jew. I can already hear you saying "pssshhh LAME" or "big whoop loser" or "why didn't you do something that was actually cool?" But to me, this was actually pretty cool. By implementing a mezuzah kiss sensor, that would play Hava Nagila if I forgot to kiss it, I was able to stop forgetting to kiss it as I walked by. If you also want to be a better Jew, you should totally follow these steps to make your own mezuzah kiss sensor!

Supplies

4-battery battery pack

Breadboard

Force sensitive resistor

Jumper wires

Laser diode

Micro controller

330 Ohm resistor

10k Ohm resistor

Photo resistor

Piezo buzzer

Solid core wire

Step 1: Code

Copy my code. Be sure to change your analog and digital pins if necessary!

int photoResistor=A5;
int fsr= A0;
int buzzer= 2;
bool laserTripped=false;
int whenLaserTripped=0;
bool fsrTouched=false;
int whenFSRTouched=0;
int photoResistorReading = 0;
int minPR = -1;      // the room's ambient light reading


void setup()
{
    pinMode(buzzer, OUTPUT);

    minPR = analogRead(photoResistor);  // the room's ambient light reading

    updateFSRSensor();
    updateLaserSensor();
    Serial.begin(9600);
}


void loop() 
{
    updateFSRSensor();
    updateLaserSensor();
    Serial.println( "laserTripped ->" + String(laserTripped) );
    Serial.println("fsrTouched ->" + String(fsrTouched) );
    delay(200);


    if(laserTripped&&fsrTouched==false&&millis()-whenLaserTripped>=200) 
    {
        tone(buzzer, 587);  //d
        delay(500);
        noTone(buzzer);
        delay(100);
        tone(buzzer, 587);  //d
        delay(750);
        noTone(buzzer);
        delay(100);
        tone(buzzer, 740);  //f#
        delay(250);
        tone(buzzer, 622);  //d#
        delay(250);
        tone(buzzer, 587);  //d
        delay(250);
        noTone(buzzer);
        delay(100);
        tone(buzzer, 740);  //f#
        delay(550);
        noTone(buzzer);
        delay(100);
        tone(buzzer, 740);  //f#
        delay(750);
        noTone(buzzer);
        delay(100);
        tone(buzzer,880);   //a
        delay(250);
        tone(buzzer, 784);  //g
        delay(250);
        tone(buzzer, 740);  //f#
        delay(250);
        noTone(buzzer);
        delay(100);
        tone(buzzer, 784);  //g
        delay(500);
        noTone(buzzer);
        delay(100);
        tone(buzzer,784);   //g
        delay(750);
        noTone(buzzer);
        delay(100);
        tone(buzzer, 932);  //bflat
        delay(250);
        tone(buzzer,880);   //a
        delay(250);
        tone(buzzer, 784);  //g
        delay(250);
        noTone(buzzer);
        delay(100);
        tone(buzzer, 740);  //f#
        delay(500);
        tone(buzzer,622);   //e
        delay(500);
        tone(buzzer,587);   //d#
        delay(1000);


        noTone(buzzer);

        resetSensors();
    }
}


// Update the FSR sensor reading
void updateFSRSensor()
{
    int fsrValue = analogRead(fsr);
    Serial.println("FSR value -> " + String(fsrValue) );

    if(fsrValue > 1000)
    {
        fsrTouched=true;
        whenFSRTouched=millis();
    }
    else
    {
        fsrTouched=false;
        whenFSRTouched=0;
    }
}


// Update the light sensor reading
void updateLaserSensor()
{
    photoResistorReading=analogRead(photoResistor);
    Serial.println("PR value ->" + String(photoResistorReading) );

    if( photoResistorReading+800 <2200)    // 800 above the base line reading
    {
        laserTripped=true;
        whenLaserTripped=millis();
    }
    else
    {
        laserTripped=false;
        whenLaserTripped=0;
    }
}


// Resets both sensor reading values
void resetSensors()
{
    laserTripped=false;
    whenLaserTripped=0;
    fsrTouched=false;
    whenFSRTouched=0;
}


Step 2: Electronics

Above are the electronics on a large breadboard for testing, followed by pictures of the electronics in the doorway. I am going to describe the steps for the circuit in the doorway, not testing.


  1. Measure the distance between the middle of your Mezuzah, and where you want to put your breadboard with the micro controller. My distance was 32 inches. Cut two pieces of solid core wire to the length you just measured. I used a red wire for my anode and a black wire for my cathode, but you can use any colors you want. I suggest using different colors in order to better keep track of which wire is the anode and which is the cathode. Solder the cathode to one side of the FSR and the anode to the other (it doesn't matter which side is which).
  2. Next, measure the distance between the breadboard and the floor, subtracting the height of the laser. My distance to the floor was 32 inches, and my laser diode with its battery pack was 2.5 inches tall, making my total distance 29.5 inches. Cut an anode and a cathode wire to the length you measured, and solder one to each side of the photo resistor (it doesn't matter which side is which).
  3. To see my bread board wiring in detail, you can use the last image in the series above as guidance. Feel free to make any necessary changes to the analog pins you choose. Thiss breadboard will be mounted between the mezuzah and the laser diode, with the FSR being mounted on the mezuzah, and the photo resistor being directly across from the laser diode.
  4. Solder the laser diode to the two wires coming out of the battery pack. Make sure that the cathodes and anodes line up with each other. I chose you prop my laser diode up a little bit more with a small cardboard box, however, you should do what's best for your space.
  5. To put it all together, you will affix your breadboard on your door frame (I made a small cardboard box for the bread board that could open and close to keep all the wires out of the way. This is totally optional, but it worked for me, and made for a more aesthetic project.) Next, take the FSR and attach it to your mezuzah (I used scotch tape to affix the FSR). Next set up your laser on the opposite side of the doorway from the rest of your electronics. I suggest turning on your laser, and then adjusting your photo resistor so that it's in the middle of the laser beam. This will ensure the most accurate reading.

Step 3: Video

Above is a video of my working project. Take a look!