This simple circuit is built around a CD4013 IC which contains two independent D type flip flop which exists in one of two states and can store information. Each module is further equipped with a group of pin outs assigned as data, set, reset, clock input and a couple complementary output Q and . As we know it has couple of output that change or toggle state as response to trigger applied to input terminals.
CD 4013 comes in 14 pin dual inline package. To understand the working of circuit first we have to understand its pin lay out.

Fig. 2: Pin Diagram Of CD 4013 IC
1.Pin number 1, 2, 13 and 12 are called as complimentary outputs hence both are available as the output means both output stages (high and low) are available. This set of output changes stage while setting and resetting the IC producing opposite logic level at any instant when operated in bistable mode.
2. Pin 5 and 9 are called as Data pins they are generally connected to one of the output may be Q or for the purpose of lengthening the applied input clock for square wave and for other waves they may be terminated to any other logic level means they may be connected either connected to supply or to the ground of the circuit.
3. Pin 3 and 11 are called as Clock input this are input pin used to receive clock signals generally in the form of square wave this signals may be provided by the transistor in the form of astable multivibrator or with the help of NAND gate or by NOR gate. And this input will produce effect on any of the output pin the other being connected to Data pin as explained above. In our circuit we are providing clock signal through a switching circuit.
4. Pin 4, 6 and 10, 8 are called as set and reset pin whenever any of the pin goes high we will get the output. When set and reset are low output shows that data at input at the time of last low to high clock transition means output is held till the next transition. For safety these are also assigned to a logic level generally they are grounded with a high value resistor. Once this is done the input can be made to alternately respond to positive peak pulses to toggle the logic stage of the Q and output alternately.
5. Pin 14 and 7 are called supply and ground pin respectively. Pin 14 receives the positive supply input which should not exceed 15V otherwise it will destroy the IC and pin 7 is ground or connected to negative supply input of IC.
Now you can also see this in truth table-
CLk | D | R | S | Q | Q- |
low-hi | 0 | 0 | 0 | 0 | 1 |
Low-hih | 1 | 0 | 0 | 1 | 0 |
Hi- low | X | 0 | 0 | Q | Q |
X | X | 1 | 0 | 0 | 1 |
X | X | 0 | 1 | 1 | 0 |
X | X | 1 | 1 | 1 | 1 |
Assemble the circuit properly and apply power supply. From circuit diagram you can see that we have connected switch S1, S4, S5 and S8 to pin 3 and 11 of IC1 and IC2. Pin 3 and 11 are clk input pin, when they receive input from switch this pin (3 and 11) goes high and provide you the output.
In this pin 13 of IC1 is connected to pin 5 of IC2 so that output signal from switch S1 and S4 to be provided to IC2 (for resetting the counter as we are obtaining output from IC2). In short we have used it to cascade the two CD4013 IC. You can also cascade more number of CD4013 IC to increase the complexity just connect the pin 13 of IC2 to pin 5 of another IC.
We have connected the reaming switches S2, S3, S6, S7 to reset pin 6 and 8 of IC1 and IC2. So whenever anybody presses this switch circuit reset itself.
Now when correct sequence S1, S4, S5, S8 is pressed then pin 13 IC2 gets a high signal. And the transistor connected to it start conduction which in turn energizes the relay connected to it and through relay you can connect your alarm. This will also be indicated with the help of LED connected to it. We have used resistor R1, R2, R3, R4 and R5 and Capacitor C1 to eliminate the effect of switch bouncing.