Clap Switch for light (home automation)

In this project we will make two clap switch circuit for AC appliances such as light and fan, using which we will be able to turn it on or off using your clap. It will be ‘ON’ on two claps at interval of less than 500ms and turn ‘OFF’ on one clap. For this we will use a CD4017 IC. So, first we will know about this IC.

Introduction to CD4017 for clap switch

This is a decade counter IC with 10 decoded outputs. It is 5-stage Johnson counter. Inputs on this chip are clock, reset and clock inhibit/enable signal. This counter provides one count at every positive clock transition if the clock inhibit signal is low. Counter increment via clock line is inhibited when clock inhibit signal is high. A high reset pulse reset the counter to its initial (zero) count.

Figure shown above is pin diagram of CD4017. As you can see that it has 10 decoded output pins which have number labeled. Carry out is also an output. It stays high when counter is between 0-5 and stays low from 6-9. Let’s see its timing diagram.

You can now easily understand the function of CD4017 using this timing diagram.

Logic diagram of CD4017

We will now see the logic diagram of CD4017 IC and try to understand it’s block diagram and construction.

Here is the logic diagram. You can see that it has a Johnson counter and a decoding circuit as labeled. 4 stage Johnson Counter counter is used to count up to 10 in BCD and decoding circuit is used to decode that count in decimal and pull the equivalent pin high.

It has additional logic circuit for clock inhibit, reset etc.

Applications of CD4017 IC

  1. Decade counter/decimal decode display
  2. Binary counter/decoder
  3. Frequency division
  4. Divide by N counting

Circuit diagram of clap switch using op-amp

For clap switch to work and be able to control the light, we need such electronics component which can convert sound wave signal into electrical signal and we all know that microphone can do this job easily. We need a high enough voltage pulse for CD4017 clock pulse at every clap. For that we need a comparator. So, now let’s see the circuit for it.

To design the clap circuit we need following components.

Components Amazon link for India Amazon link for other countries
CD4017 decade counter https://amzn.to/3Krt2E6 https://amzn.to/3IwBXT7
Resistors (22kΩ, 1kΩ, 470Ω,10kΩ, 220Ω,500kΩ) https://amzn.to/3tMIrsT https://amzn.to/3nMCR5K
one potentiometer (1k) https://amzn.to/32nCeZ9 https://amzn.to/3qSv3BI
diode (1N4001) https://amzn.to/3AolkpH https://amzn.to/3tPHvnI
Capacitor (1uF) https://amzn.to/3qMTgJw https://amzn.to/3GMfxN7
741 op-amp https://amzn.to/3ItnMOI https://amzn.to/3tXjRp0
Microphone https://amzn.to/35fwX6X https://amzn.to/3GR6AlJ

Working of clap circuit using op-amp

This is circuit of clap switch using op-amp. As you can see that it has a microphone which converts sound wave into electrical signal. This signal then compared to a reference voltage using a comparator. Microphone signal is connected to inverting terminal of comparator and reference voltage is connected to non-inverting terminal of comparator. If the microphone signal voltage is greater than reference voltage then output of comparator will be high. We can change the reference voltage using variable resistor RV1 and hence we can change the sensitivity of the clap circuit.

Clock pin of CD4017 is connected to the output of comparator and it pulled down to ground using R5. At every clap 4017 will get a high pulse at its clock pin and its output will get increment. At initial condition output number ‘0’ of 4017 will high.

If one clap rings, one pulse will applied to 4017’s clock pin and its counter will increment by one. Now output number ‘1’ is high so, capacitor C1 starts charging through resistor R1. Here the reason why diode D2 is connected is to prevent current flowing through resistor R1 to output number ‘3’. If this diode is not connected, capacitor will not charge.

Now if second clap doesn’t rings till charge on capacitor reaches high threshold voltage. Then 4017 reset at a constant RC time since positive terminal of capacitor is connected to “master reset” of 4017. After that output ‘1’ is low so capacitor starts discharging through R1 to pin 2 (output ‘1’). If second clap rings before 4017 resets, then it increment its counter to output number ‘2’ and stays high till third clap rings. And as third clap rings, 4017 increment its counter again. As 4017 increment its counter then output ‘3’ is active and it reset the 4017. Whole process repeats and this way this circuit works. We can add a relay to output ‘2’ to operate AC appliances using clap.

Circuit diagram of clap switch using 555 timer IC

Above circuit have some bugs. It may trigger more than one time on only one clap because claps generate vibrations and according to that vibration microphone will send voltage vibration to the comparator. So, comparator may false trigger. To prevent false triggering we need some short of switch debouncing circuit. For that we will NE555 timer IC in monostable mode.

To design the clap circuit we need following components.

Components Amazon link for India Amazon link for other countries
NE555 timer IC https://amzn.to/3AmxZcI https://amzn.to/3AlKmG1
Resistors (4.7kΩ, 1kΩ, 470Ω, »35kΩ, 220Ω,500kΩ) https://amzn.to/3tMIrsT https://amzn.to/3nMCR5K
2xBC547 or 2n222 transistors https://amzn.to/3rzcrpa https://amzn.to/3u54wTN
diode (1N4001) https://amzn.to/3AolkpH https://amzn.to/3tPHvnI
Capacitors (2x1uF, 0.1mF, 10nF) https://amzn.to/3KyzLfB https://amzn.to/3GMfxN7
CD4017 decade counter https://amzn.to/3Krt2E6 https://amzn.to/3IwBXT7
Microphone https://amzn.to/35fwX6X https://amzn.to/3GR6AlJ

Working of clap circuit using 555 timer IC

This is the circuit of clap switch using 555 timer IC.  In this circuit signal is from microphone is amplified using two BC547 transistor. That amplified signal then connects to the trigger pin of 555 timer IC which is in monostable mode.  Its time constant is around 40ms that means if the IC is once triggered its output will be high for 40ms, no matter how many times it gets triggers in that 40ms duration. After 40ms output will get low. And if another trigger happens after 40ms then its output will high again for 40ms and this cycle repeats. This way we got a clean debounced signal at clock input of 4017 IC.

See this graph for better understanding –

Now you can control AC light or fan using this clap switch by adding a 5v relay to its output. Let’s see the circuit.

Leave a Comment

Your email address will not be published. Required fields are marked *