Microcontroller Clapper Switch

Not rated 9,338

Circuit Image

For those who prefer convenience, it is possible to turn the bedroom light on or off without leaving the bed simply by clapping hands. This concept inspired the design of a clap-activated light control system. Various clap switch projects can be found online, most of which do not utilize a microcontroller. However, a microcontroller was chosen for this design to allow for future enhancements, such as turning on or off the light with two claps, the TV with three claps, the DVD player with four, and so forth. Another potential enhancement is to implement a timer to automatically turn off the device. The hardware design is straightforward, consisting of a microcontroller, an electret microphone, a relay, and several discrete components. An ATmega8 microcontroller serves as the central processing unit for this project. The microphone captures sound, which is then amplified by a BC548 transistor. This amplified signal passes through a low-pass filter to eliminate high frequencies before reaching the ADC of the ATmega8. To maintain simplicity, only one transistor is used for signal amplification. Two buttons are provided to adjust the sensitivity of the system. The complete schematic is available below, with optional components indicated by a dotted line. The software was developed in C using AVR Studio and the WinAVR library. The ADC is continuously monitored, and the returned value is compared to a user-defined variable. This variable can be altered by pressing buttons S1 or S2, enabling the user to increase or decrease the required signal intensity to activate the circuit. If the ADC value is below the variable, no action is taken; if it exceeds the variable, Timer0 is activated and begins counting. During each timer overflow, a variable named 'timer' is compared against three constants: burst_time, ready_time, and time_out. When the timer equals burst_time, a global variable 'burst' is set to 1. When the timer equals ready_time, 'burst' is reset to 0 and another variable 'ready' is set to 1. If the timer reaches time_out, all variables are reset to 0. Upon detecting another clap, if 'burst' equals 1, the microcontroller resets all variables and restarts the loop. If 'burst' equals 0 and 'ready' equals 1, the output state is toggled.

The clap-activated light control system is designed to enhance user convenience by allowing for hands-free operation of lighting and other electrical devices through simple auditory commands. The system operates based on sound recognition, where the microphone captures the sound of claps and processes the signal using a microcontroller. The ATmega8 is selected for its adequate processing power and availability, making it suitable for this application.

The electret microphone serves as the primary input device, converting acoustic energy from claps into an electrical signal. The BC548 transistor amplifies this signal, ensuring that it is strong enough for processing. The low-pass filter is crucial in this design, as it removes unwanted high-frequency noise that could lead to false triggering of the system.

The adjustable sensitivity feature, controlled by buttons S1 and S2, allows users to calibrate the system according to their environment, making it versatile for different settings. The software logic implemented in the microcontroller ensures that the system is responsive and can handle multiple claps without misinterpretation.

The timer functionality adds an additional layer of control, allowing for automated device management. This feature can be particularly useful for energy conservation, as users can program the system to turn off devices after a specified period of inactivity.

Overall, this clap switch project exemplifies a practical application of microcontrollers in creating user-friendly electronic solutions, demonstrating both simplicity in hardware design and sophistication in software logic.For those who are lazy like me, turn on or off the bedroom light without getting out of bed, simple clap your hands is amazing. Thinking about it I projected one for me. Several projects of clappers can be found on the Internet, and most of them do not use microcontroller.

I chose to use a micro planning future updates, such as turn on or off the light with 2 claps, the TV with 3 claps, DVD player with 4 and so on. Another update can be a time to turn off the device automatically. The hardware is very simple, just a microcontroller, a electret mic, a relay and some discrete components. The microcontroller is the brain of the project, I used a atmega8 because it was the only I had available.

The signal is captured by the mic and amplified by the transistor (BC548), this signal run through a lowpass filter that remove the high frequencies and go to mega8 ADC. To keep the circuit simple, only one transistor is used on signal amplification. Two buttons are used to up or down the sensibility of the signal. You can see the complete schematic below. The components on dotted line are optional. The software was written in C using AVR Studio and WinAVR library. The ADC is read constantly, and the returned value is compared with a variable. This variable can be changed if the user press the button S1 or S2. So, the user can increase or decrease the intensity of the signal necessary to trigger the circuit. If the value of the ADC is less than the variable, nothing happens, otherwise the timer0 is activated and begins counting.

At each timer overflow, a variable called The value of variable timer is compared with three constants, burst_time, ready_time and time_out. If the value of the variable is equal to the constant burst_time the value of global variable burst become 1.

If the value of timer is equal the constant ready_time the value of variable burst becomes 0 and variable ready becomes 1. If value of timer is equal time_out all the variables become equal to 0. When another clap is detected, if burst = 1 then the microcontroller clear all variables and start the loop again.

If burst = 0 and ready = 1 the output is toggled. 🔗 External reference




Warning: include(partials/cookie-banner.php): Failed to open stream: Permission denied in /var/www/html/nextgr/view-circuit.php on line 713

Warning: include(): Failed opening 'partials/cookie-banner.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/nextgr/view-circuit.php on line 713