A customer asked us if a HomeWorks QS keypad could be used as a combination lock. We thought this programming sample would be useful for the forum community.
Attached is a sample project file where the buttons need to be pressed in the order of 1/4/2/3 for the output on the QSE-IO to pulse. If any other combination is used the CCO will not pulse when button 3 is pressed.
To accomplish this programming there is a state variable called "combination lock". This variable has a reset state and a state for buttons 1, 2 and 4. There is also an automatic sequence for buttons 1, 2 and 4. These sequences set the variable to the corresponding button on preset 1 and have a 5 second dwell time. On step 2 the variable gets set back to the reset state. This is so if a button is not pressed after 5 seconds the order in which the buttons need to be pressed will need to be started over.
On the keypad buttons they are conditionals. The correct press order on buttons 1, 2, and 4 stop the previous sequence and start the sequence for the button that was pressed. A press out of order stops all sequences and sets the variable back to the reset state. On button 3, a correct order press pulses the CCO and sets the variable back to the reset state and an incorrect press stops all sequences and sets the variable back to the reset state. On the press tab of all the buttons there is an If Else statement. If the variable is in the proper state, the correct press action is executed else the incorrect press action is executed. For example on button 4 if the variable is in the "button 1" state then the correct press action is executed else the incorrect order press action is executed.