Go Down

Topic: Door Knob Touch Alarm (Read 2756 times) previous topic - next topic

Big Oil

Version 1.0  If the door knob is touched (from the other side of the door) the alarm goes off.



I wired a 10 uf capacitor in series with a 1 mega-ohm resistor from 5v to Analog0 like this:



The Arduino is hanging on the doorknob by the loop in the wire.  AnalogRead records the change in values.  If the wire is touched directly then analogRead drops quite a bit, if the doorknob is touched on the other side of the door, it drops just a little bit.  
I also wired a potentiometer so that the sensitivity can be adjusted and the alarm will be activated by that small drop in value.

Code: [Select]
//When someone touches the doorknob the analogRead value from the wire drops a bit.

int sensorPin = 0;  
int ledPin = 13;      
int sensorValue = 0;  
int pot;
int sensor;

void setup() {
 
 pinMode(ledPin, OUTPUT);  
 Serial.begin(9600);
}

void loop() {
 sensorValue = analogRead(sensorPin); //the doorknob sensor wire
delay(10);  
pot=analogRead(5);  // the potentiometer is connected to analog 5

Serial.print(sensorValue);  //sensor wire value
Serial.print("      ");
Serial.println(pot);        //potentiometer value
delay(100);

if(sensorValue<pot){   // this allows you to turn the potentiometer to a sensitive borderline value
                      // when someone touches the knob it dips just below the pot value

    digitalWrite(13,HIGH); //the led (alarm) lights up.  This could be replaced by a buzzer
    delay(100);
    digitalWrite(13,LOW);
}
 
 
}


For the next version:  
I don't have a wide variety of capacitors and resistors to experiment with so there may be a better combination.  
Also, the LED could be replaced by a buzzer.

Go Up