Software apps and online services
Hand tools and fabrication machines
Makers always look at the simplest and shortest way to get things done. So, today we will learn how to control our home light switch in the simplest and quickest way.
Today, we will learn how to control home light switches by just hand-clapping, Cool ha! to build that project we will use some new electronic components like the decade counter CD4017 IC and the UA741 op-amp and a condenser MIC as a sound sensor. So, let’s do it
The main part of the project is sensing the hand-clap, we used an electret condenser MIC to do that job. which converts the sound energy into electrical energy. this electrical signal will be an input signal to the UA741 IC. that electret MIC is very sensitive, easy to use and cheap.
After sensing the hand-clap, the generated electrical signal will go to the input pin of the UA741 op-amp which works in this project as a comparator, the UA741 IC will compare the MIC input signal with a specific reference voltage if the input signal is higher than that reference voltage it will output logic value “HIGH”. And will output “LOW” when the reference voltage is higher than the input voltage.
We are using a potentiometer connected with the UA741 chip to adjust the reference voltage, which works just as setting the sensitivity of the circuit.
The UA741 IC output value goes to the “Clock” pin of the counter 4017 IC to turn on and off the relay.
- Driving high voltage/current load
You know, we are building this circuit to control AC high voltage loads. So, we used a 5VDC relay to make our small poor circuit able to communicate with that beefy AC high voltage load.
The typical use of the UA741 IC is to amplify a specific signal. Essentially it takes an input voltage, amplify it by a specific gain, then outputs an amplified voltage. That’s it. It’s mostly used in the speaker circuits to amplify the input signal to make the sound loud and clear.
But today, we will use the UA741 op-amp as a comparator, not as an amplifier.
As you can see, there’s a positive pin called “non-inverting terminal” and the negative pin called “inverting terminal”. these two pins are the input voltage pins. Also, there’s the voltage output “Vo” pin, and obviously the two power supply pins VCC, and GND.
Since the gain naturally of the op-amp is very huge, then what happens when we feed the op-amp two input pins?
If the input voltage on the positive terminal“Non-inverting pin” is higher than the input voltage on the negative terminal “Inverting pin” Even by a tiny amount. the op-amp will try to amplify the difference between those two inputs by a huge gain and the output voltage from the op-amp will equal (the difference between the two input voltages * the huge gain) which is a very large amount like hundred and hundred thousands of volts or something. But it can’t do it since you are powering your circuit by a 12V or 5V or even 15V.
As a result, it will saturate at the amount of voltage which you are powering your op-amp with. Which is the VCC.
Vice versa, if the input voltage on the negative pin “inverting terminal” is higher than the input voltage on the positive pin “non-inverting terminal” even by a tiny amount, the output voltage will equal the -VCC (GND).
As a general rule, when the positive pin(Non-inverting pin) input voltage > the negative pin(inverting pin), the output voltage will equal to +VCC. And if opposite the output voltage will equal to GND
- Pin 1 and 5(Offset null)
We can set the op-amp gain value by connecting a capacitor on pins 1 and 5 but we don’t have to use those pins in this application, we will keep them unconnected.
- Pin 2 and 3(Inputs)
Voltage input pins. We are connecting a potentiometer on the negative terminal (Inverting pin) to adjust the sound sensor sensitivity (Reference voltage). So, you can make the sensor very sensitive and feel the hand-clap from a long distance. Or decrease the sensitivity if there’s a lot of noise around you or something.
- Pins 4 and 7(GND, VCC)
Easy! it’s the power supply pins. Pin 7 is VCC and 4 is GND. This chip can handle an input voltage from 5V to 15V.
- Pin 6(Output)
The voltage output pin.
- Pin 8(Not Connected)
Pin 8 is unconnected.
Each output of this chip will turn on, one at a time, sequentially or in succession. For example, let’s say that we are connecting ten LEDs with the chip. Each LED is connected on a different output pin, each LED will light, one at a time unless all have been turned on at the same time. After it reaches the last output pin(Q9) it will start over again and repeats and repeats infinitely.
This IC called decade counter because it’s simply can count from 0 to 9 or from 1 to 10 and that’s why this IC named “Decade” (remember it, a decade is made up of 10 years) Actually, I wanna kiss the guy who came up with that name.
This counting behavior is working by a command from the 4017 IC “Clock” pin which plays a big role in 4017chip, without this pin the chip will not work at all. Once the “Clock” pin goes from LOW to HIGH, at this point the chip knows that it is the time to turn off the current output and turn on the next output. So, it knows when to act based on the clock signal.
- Pins 1, 2, 3, 4, 5, 6, 7, 9, 10, 11
It’s the output pins where we place the load which we need to control. The outputs are numbered from Q0 to Q9. In our case, we will use only two output pins (Q0, Q1) to turn on and off the relay, the transistor which controls the relay state will be connected on Q0, and a normal LED on Q1 to indicate that the relay state is off.
- Pins 8 and 16(GND, VDD)
Power supply pins, this chip can handle an input voltage from 3.3V to 18V.
- Pin 15(Reset)
It resets the count back down to output 0 (Q0), normally it’s grounded. This means when it brought to a HIGH logic level it will reset the count down back to output 0 (Q0).
- Pin 14(CLK)
As we stated before, It’s the pin that tells the chip when to start/stop counting.
- Pin 13(EN)
The enable pin is an active low pin, which means it will normally be connected to ground to make the chip active and operating properly, once it brought to a HIGH logic level, the chip will stop operating.
- Pin 12 (CO)
The carry-out pin remains HIGH as long as the counting is on the first half(Q0 – Q4) and it turns LOW when the counter reaches the second half(Q5 – Q9).
Relay is an electromagnetic switch that turns on/off a circuit with a low power signal. Like in our case we need to drive a 220VAC load. But, our circuit can’t do that on its own so we added a relay to switch the AC on/off by the CD4017 output signal.
It’s very important to add a diode to protect your controller or your IC from any back-EMF.
We a re using a 5VDC relay which has 5 pins as shown in the figure below.
How Do Relays Work?
Simply, the relay is just an electromagnetic switch operated by a small voltage that can control another high voltage/current circuit.
Relay’s most important component is the coil, it consists of a coil that turns into a magnet once a current flows through it. when a current flows through the coil there is a magnetic field that will get generated to attract a contact to turn on (close) the load circuit.
And vice versa, when there is no current is flowing through the coil, a spring will attract the contact back to its original position to turn off(open) the load circuit.
The “COM” is the contact that closes or opens the load circuit based on the coil state, is it energized or not?The “Normally Closed” (NC)” is the pin that is closed by default when there is no current flowing through the coil, it will get disconnected from the COM pin only when current flows through the coil. “Normally Open” (NO) is the pin that is opened by default when there’s no current flowing through the coil, it will get connected with the COM pin only when current flows through the coil.
This circuit works on 12V, not 9V.
I designed this circuit using Autodesk Eagle software. all the PCB files are open-source you can access it from this link. Because we love open source.
You can order your own PCB From PCBWay company these guys have a very good reputation in this field and they ship to more than 170 countries around the world with reasonable prices. all you have to do is to open the project PCB files link and press “Add to cart”. That’s it!
I will assume that you built it and you are happy now. CONGRATS FAM! in this tutorial we learned how does the CD4017 decade decoder IC work, also we learned how to use the UA741 op-amp as a comparator, and how to drive an AC voltage load using a simple relay. Lastly, we build a hand-clap AC control switch which is dope!