Use a reed switch, and either pull a pin high or low.

As many switches can be connected in series as needed in either circuit.
The output will change only when all are CLOSED, or even one is OPEN.

Either way, a cut wire to the switch will sound an alarm.  Poll the port
connected to the switch for 100 mS if you see a transition, watching for the
same state, and reset the 100 mS timer if the state changes between polls,
to avoid triggering on noise.

Only after the same state has been polled for 100 mS do you consider that
state valid.  You will wake up in the middle of the night less frequently.

The 12V battery should be float charged to 13.8V max. (lead acid example).
This will give a long stand-by time, and drive a siren if desired.

In long signal runs, a small cap across the PIC input to ground (1 uF, 25V,
positive to the PIC pin, negative to ground) will help eradicate noise.

ckt 'a' This makes a logic 1 when reed sw is closed

Note: put 22K and Zener near PIC pin.

+12V >--39K----o/ o----+----+--> to PIC pin
             reed sw   |    |
                      22 K _|_/
                       |   /_\  1N4733
                       |    |
  0V >-----------------+----+--> to PIC ground

ckt 'b' This makes a logic 0 when reed sw is closed

Note: put 22K and Zener near PIC pin.

+12V >--39K------+----+-----+---> to PIC pin
                 |    |     |
                 o    |    _|_/
        reed sw   \  22 K  /_\  1N4733
                 o \  |     |
                 |    |     |
  0V >-----------+----+-----+---> to PIC ground

Kool Breeze wrote in message <>...
>Looks like I am gonna get a basic stamp for my needs.
>I now have two. I wish to detect when a door/window is
>open. The basic stamp inputs 5v == 1 or 0.6v (or less) == 0.
>What's the best way to run wiring from windows/doors
>(using a 12v battery) to do this?

Date: Wed, 16 Dec 1998 00:12:51 -0600

Original Subject: Re: RS232 Control - Almost Solved...Thanx!!

Comment on this article

Comments on this article

This article is referenced in the following indexes: