Just know this will be my first time using an ARDUINO so please be kind.
Goal: We work in a very loud area and need to ring a Bell each time the front door is opened.
Here is what I already have: A door that has a sensor already in it that is hard wired back to the area I will need the bell. The door sensor was from an old alarm system, I have tested it and it does still work. The bell is 120vac and is very loud. I would prefer the bell only ring for a few seconds each time the door is opened.
What kind of sensor? Tested it how? What does still work mean?
If it is a simple switch, and "still works" means that it still makes/breaks a connection, it is very easy to connect that to an Arduino and read the connection state.
Connecting the bell will require a relay and a transistor. The Arduino toggles the transistor, which activates the relay, which activates the bell. After a time, the Arduino toggles the transistor again, which deactives and relay, which causes blessed silence.
Door Sensor is Magnetic type embedded in door frame. I played with alarm to see if I could use it for this without success. Doing this I was able to determine the door sensor still works.
Is Magnetic sensor compatible with Arduino?
I'll ask again. You said you tested the sensor, and that it works. HOW did you test it? If the sensor is mounted on the frame, and there is a magnet on the door, the thing is a simple switch. The mechanism for the make/break is irrelevant.
OK. So, connect one side to ground and the other side to a digital pin. Activate the internal pullup resistor. Read the switch. HIGH means the door is open. LOW means that it is closed.
Something like this:
const int switchPin = 7;
const int relayPin = 8;
int currState;
int prevState = LOW;
void setup()
{
Serial.begin(115200);
pinMode(switchPin, INPUT);
digitalWrite(switchPin, HIGH); // Turn on the pullup resistor
}
void loop()
{
currState = digitalRead(switchPin);
if(currState != prevState)
{
// Door just opened or door just closed
if(currState == HIGH)
{
digitalWrite(relayPin, HIGH);
}
else
{
digitalWrite(relayPin, LOW);
}
}
prevState = currState;
}
You can change the code to debounce the switch, or to keep the relay HIGH for a period of time, instead of shutting off then the door is closed.
I would do it the relay way but the switch in the door is normally closed, backwards for an easy solution. I would go that way because now I want an Arduino just to play with.....
You can learn more about Arduino and later add functions like "Nobody CLOSED the door after 60 seconds. Do 2 short rings". Etc Etc. whatever you can imagine.
I get the ominous feeling you should leave this door contact alone, especially after reading that you tested it's functionality by turning on an alarm. Taking the contact off the system or using varied resisters will likely screw your alarm up, keeping it attached and hooking it to voltage could permanently damage the alarm system.
What kind of security system is it? Some systems, for example a Bosch D6412, can be setup to watch contacts, and activate outputs on the board that can in turn close relays to a 120VAC bell. I had my home motion detectors setup to bypass the light switch in my hallway and turn on the light for 30 seconds on movement at one point.