Disabling Alarm system with Hex Keypad
TJRyan
Posts: 18
Hello,
I am trying to figure out a way to disable an alarm system using a Hex (4x4) keypad. I am using two micro-controllers; one for the alarm itself, and a second one for the keypad. For the second micro-controller, i am looking for a code that will be able to not only disable the alarm using a set code, but also reset the entire system. The code used for this will be simply; "1, 2, 3, A"
Thank you
I am trying to figure out a way to disable an alarm system using a Hex (4x4) keypad. I am using two micro-controllers; one for the alarm itself, and a second one for the keypad. For the second micro-controller, i am looking for a code that will be able to not only disable the alarm using a set code, but also reset the entire system. The code used for this will be simply; "1, 2, 3, A"
Thank you
Comments
It will be very hard to answer your question with the limited amount of information supplied.
Which microcontroller(s) are you using? The code that yuo are using currentley would be helpful.
I mean like the sample below.
The system monitors:
6 switch contacts on windows and doors.
3 motion sensors on the main floor
1 signal from the fire alarm system
1 panic switch
The system ccontacts:
Monitoring company if switches or motion sensors are active
Monitoring company and fire department if fire alarm is active
Monitoring company and Police if panic switch is activated
It has:
1 IR sensor
1 Piezo buzzer
2 Basic Stamp Board of Education micro-controllers
1 Hex Keypad
It is armed with an IR Beam that hits an IR sensor
Once the beam is broken and the Sensor stops sensing IR light, the alarm (which is a simple piezo buzzer) will begin to sound at a set interval.
Once the buzzer goes off, the second microcontroller will activate
Once it is active, the proper keypad input must be put in (This input will be simply, 1,2,3,A-top left to top right)
Once the code is properly sequenced, the ENTIRE system (both micro-controllers) will deactivate and will bring it back to the first micro-controllers first line of code (which simply looks for IR light at the sensor)
I know how to write the code for the first micro-controller, what i dont know how to do is sequence the keypads inputs, and also how to reset the system once the proper sequence is put in
OK, then you can download the sample programs for the keypad as a starting point. The simplest interface between the two micros would be to use two pins on each.
Alarm micro...............Keypad micro
alarm_out->>>>>>alarm_in
valid_code_in<<<<-valid_code_out
When the alarm_out is high the keypad micro reads 4 digits from the keypad and if they are the correct code outputs a high on the valid_code_out pin. The alarm micro turns off the alarm when it receives that high.
and is this how i would write the code in the Basic Stamp Editor?
You can find the keypad code here.
For safety you should put resistors between the pins rather than connecting them directly. 1K would be good. Same goes for the keypad. Page 3 of the keypad manual shows where they go. They prevent damage to the pins in case of a bug in the program.
So if I understand this correctly, I need to add in 10k pulldown resistors to the first four input pins?
There are two concerns with this keypad if used directly.
The first is possible damage to the I/O pins if a button is pressed and the code has the two pins connected to that button set to outputs with one pin high and the other low. Very easy to do when debugging code. Even if the code is perfect a short between pins can happen if two buttons are pressed at the same time. Series resistors between the pins and the keypad will prevent that.
The second is floating input pins. This can lead to false readings. Since a button is connected between one row and one column only one input is connected to an output so three of the inputs are floating. Pull down or pull up resistors can solve that.
So i would already be adding resistors to the connections between the pins and Keypad. Do i have to add 1K resistors to every single one of the pin connections? Or just to the ones shown on the data sheet? Also, would i now just have to add 10K resistors to each keypad connection and use them to connect to either ground or power?
So, all of the wires are connected using 120 ohms, and connection 1 also has a 10k connection to ground?
All the wires have 120 ohms, but there are 4 wires ( 1, 2, 3, 4 ) with 10K resistors to ground.
Nope, it should connect to the same I/O port pins on the microcontroller.
i.e.
IF
Keypad1 HIGH
THEN (whatever would be done to move the sequence)
The is example code for reading the keypad is in the "4x4MatrixKeypad_Demo.bs2" file, although that is not necessarily the best way to do it for your use.
If you are using a BS2 microcontroller you can use a FOR loop and a SELECT CASE statement to decode the keypresses, if you are using a BS1 there is no SELECT CASE so you would need IF THEN or some other way of decoding it. Do you need the decoded value to match the number/character on the keypad button?
Yes, i need it to be able to read the inputs so when the correct buttons are pressed, the valid_code_out pin goes HIGH, resetting the whole system
BS2