Desk Guard

The purpose of the Desk Guard is to protect your personal belongings from nosey friends and people intruding into your personal space. This is done by bringing attention to these nosey friends and people intruders that pass by when you get away from your desk. It starts by powering on the Arduino before you step away from your desk and pointing the infrared sensor in the direction people will be walking up to your desk. Then just listen and wait. An occasional beep is okay, but when you or one of your friends hear a rapid beep, that means someone is standing next to your desk.


/*
Desk Guard

Buzzer sounds based on human proximity.

Infrared sensor detects the distance from nearest person to the Desk Guard.
The closer the intruder gets to the Desk Guard the faster the Buzzer beeps.
The purpose of the Desk Guard is to protect your personal belongings from
nosey friends and people intruding into your personal space. This is done
by bringing attention to these nosey friends and people intruders that
pass by when you get away from your desk. It starts by powering on the
Arduino before you step away from your desk and pointing the infrared sensor
in the direction people will be walking up to your desk. Then just listen
and wait. An occasional beep is okay, but when you or one of your friends
hear a rapid beep, that means someone is standing next to your desk.

This code is in the public domain.

Last modified October 12, 2015
by Edgar & Sky
*/

int buzzerPin = 12;
int irPin = 0;
void setup()
{
Serial.begin(9600); //Run the Serial Monitor to see the numbers
}

void loop()
{
int distance = analogRead(irPin);
int beepDelay = map(distance, 0, 300, 300, 0); /*ADJUST MAP ACCORDING TO
SPECIFIC DISTANCES USED*/
if(distance <= 40) { //static in the sensor gives initial readings <=40
noTone(buzzerPin);
}
else if(distance >= 41) {
tone(buzzerPin, 3000, 100);
}

Serial.print("distance away = ");
Serial.print(distance);
Serial.print("\t");
Serial.print("beep delay = ");
Serial.println(beepDelay);
delay(beepDelay);
}


Desk Guard Diagram

Desk Guard Fritzing

Video Example