Post Top Ad

Tuesday, November 19, 2024

on video how to make clap on off switch//simple clap on off switch


 how to make clap on off switch//simple clap on off switch

Today I am going to make a circuit of clapping switch. when we will clap then LED will glow. This circuit is amazing. To make this circuit I will use LM555 IC and C945 transistor.


This instructable not only gives the reader the information needed to create a clap-clap on/clap clap off switching circuit, but the logic used to make a hardware-only clap-on, clap off circuit. More information on a hardware-only version can be found in the final section of this instructable.


This circuit employs some very simple and cheap circuitry, and a simple program. It is relatively easy to make a hardware only clap on/off circuit, but I wanted to create a circuit that required two claps to switch on, and two claps to switch off. The clasps must be in quick succession, as seen in the video below, or else it does not work, which is the entire point of the circuit =) I will go into detail about the circuitry, and the program. I will also do my very best to answer any questions you guys may have. This device can be thrown together in a single evening.

The software works like this:

1) The software waits for an initial loud noise, then starts a countdown sequence.

2) If the device detects another loud noise within about 250 milliseconds, then the relay will toggle on. If the timer runs out of time without detecting another loud noise, the program resets.

3) Once two clamps have been detected, and the relay toggles on. The software then starts the same sequence over again, only waiting to toggle the relay off.

4) Once the relay toggles off again after detecting two clasps in succession, the program resets back to the original state.


Since the PIC10F222 has a limited instruction set, I had to add in some extra lines of code. I would have used the PIX18F1220, but that would have over-killed. Ah, but how I miss the BTF (Bit Toggle) instruction =)

THE VOLTAGE REGULATOR:

This step is a short one. We're going to talk about the power supply circuit.

We only need a 9v battery to properly drive this circuit. We can use 7VDC and up. The 78L05 5V regulator is used here because this is a low-power device, and we need not use a big LM7805 when we have so little space to begin with.


The 78L05 has three pins:

1) 5V-Out

2) Ground

3) Voltage-In (7VDC+)


We need only a 0.1uf ceramic decoupling capacitor between the 5v-Out line, and ground to rid the circuit of any unwanted high frequency interference that may come along. However, since we are using a battery, this capacitor is really optional. Good practice, more like. If you are using an AC-DC wall wart, it is suggested you place a 100uf electrolytic capacitor between the Voltage-In pin, and the ground line to protect against any surges on the line, and to smooth the DC going in to the regulator .

STAGE#1: The Microphone and the Amplifier

As you can see from the picture below, we have an electret microphone connected to the ground line, and to one end of a 10k resistor. The other end of the resistor is tied to the 5v line. When an audio sound is sensed by the microphone, it changes that audio signal into a voltage that emulates the tone picked up. We can use that noise, but first we have to condition it. To rid ourselves of the DC component, we AC-couple the signal using a coupling capacitor. This signal will be extremely small, so we must first amplify it. We are going to do that using a handy-dandy LM324 quad op-amp IC.

The pull-down resistor to the right of the coupling capacitor is necessary for the operation of the non-inverting amplifier stage to work. In fact, all components in the below diagram are critical. The way a non-inverting op-amp works, is it takes two values ​​RA, which is the 1k resistor connected to the (-) input and ground, and RF (100k potentiometer), which is the feedback resistor, which is connected between the (-) input, and the output, and creates a voltage gain factor. The voltage gain factor (AV) is a multiplier. Once we determine the AV, we multiply the voltage at the input by the AV, and we have our output voltage. The 100k pot is used to vary the voltage gain. This will either increase the sensitivity or decrease the sensitivity of the circuit. The equation for AV = RF/RA in a non-inverting amplifier circuit.

STAGE#2 The Comparator:

The standard MCU does not like to work with sine waves, or any odd shaped wave. That is, unless you are using the ADC, which we are not. We want to turn our now amplified waveform into a 0-5VDC square wave that can be used by the PIC10F222. What are going to emply here is the comparator circuit. A comparator does exactly as you'd think. It compares voltages. If the voltage at the (-) input is higher than the voltage at the (+) input, then the output will be 0v. If the voltage at the (+) input is higher than the voltage at the (-) input, then the output will be 5v.


We have a resistor voltage divider network at the negative (-) input. Thiswill keep a constant 1.5v at the negative input. When a loud sound is generated and amplified to a voltage higher than 1.5v, then the output will go from 0-5v until the voltage at the (+) falls below 1.5v. We only need for the output of the comparator to be high for a micro second or so, so don't worry too much about the time duration of the output of the comparator being high.

THE BRAIN (PIC10F222):

Ah the good ol' archiac PIC10F222. This chip has an on-board internal oscillator, which exterminates any necessary external driving hardware, such as a crystal oscillator. We really only need 5v, Ground, the output of the comparator, and an I/O port deduced to control the driving of the relay. So we are only using 4 out of the 8 pins. Read the software section to see how the chip is interpreting the comparator information, and how the algorithm is set up.

The Relay Switch:

In order to drive our 5v relay using the output of a PIC, we have to set up a driver circuit, which in this case is a simple NPN transistor, and a diode. The diode does nothing to drive the relay, but it acts to protect the relay coil from surges. Any coil such as this should always be protected by a diode. The 1N4004 is as good as any. The base of the transistor is protected by a 10k ohm resistor. You want to make sure that you are using this, or else you will over-drive your transistor. When GPIO,0 outputs 5v (high or set), then the base of the NPN transistor is activated, allowing 5v to pass through the internal coil of the relay, and thereby creating a magnetic field that toggles the internal switch. When GPIO,0 is cleared (0v), then the transistor is deactivated, and the path from 5v to ground along the coil stops dead. The magnetic flield then collapses, and the relay switches back to default state. In other words, if you use the configuration below, you have 5v at the common wiper of the SPDT (Single pull double throw) relay. In default setting, the wiper is connected to the NC (Normally connected) pin of the relay. When the relay is activated, the wiper connects to the NO (Normally open) pin of the relay, and power is applied to the LED. When the relay is deactivated, the wiper re-connects to the NC pin, and the path from 5v to the LED is broken.

I have done my best to comment out this program as best as I could. You should be able to follow along. It is no masterpiece, but again, I was working with an inferior instruction set. You can download the .ASM code and use it with your PIC ICD2 programmer puck, as seen in the image. I am also happy to answer any questions you may have related to the software!


 how to make clap on off switch//simple clap on off switch

Today I am going to make a circuit of clapping switch. when we will clap then LED will glow. This circuit is amazing. To make this circuit I will use LM555 IC and C945 transistor.


This instructable not only gives the reader the information needed to create a clap-clap on/clap clap off switching circuit, but the logic used to make a hardware-only clap-on, clap off circuit. More information on a hardware-only version can be found in the final section of this instructable.


This circuit employs some very simple and cheap circuitry, and a simple program. It is relatively easy to make a hardware only clap on/off circuit, but I wanted to create a circuit that required two claps to switch on, and two claps to switch off. The clasps must be in quick succession, as seen in the video below, or else it does not work, which is the entire point of the circuit =) I will go into detail about the circuitry, and the program. I will also do my very best to answer any questions you guys may have. This device can be thrown together in a single evening.

The software works like this:

1) The software waits for an initial loud noise, then starts a countdown sequence.

2) If the device detects another loud noise within about 250 milliseconds, then the relay will toggle on. If the timer runs out of time without detecting another loud noise, the program resets.

3) Once two clamps have been detected, and the relay toggles on. The software then starts the same sequence over again, only waiting to toggle the relay off.

4) Once the relay toggles off again after detecting two clasps in succession, the program resets back to the original state.


Since the PIC10F222 has a limited instruction set, I had to add in some extra lines of code. I would have used the PIX18F1220, but that would have over-killed. Ah, but how I miss the BTF (Bit Toggle) instruction =)

THE VOLTAGE REGULATOR:

This step is a short one. We're going to talk about the power supply circuit.

We only need a 9v battery to properly drive this circuit. We can use 7VDC and up. The 78L05 5V regulator is used here because this is a low-power device, and we need not use a big LM7805 when we have so little space to begin with.


The 78L05 has three pins:

1) 5V-Out

2) Ground

3) Voltage-In (7VDC+)


We need only a 0.1uf ceramic decoupling capacitor between the 5v-Out line, and ground to rid the circuit of any unwanted high frequency interference that may come along. However, since we are using a battery, this capacitor is really optional. Good practice, more like. If you are using an AC-DC wall wart, it is suggested you place a 100uf electrolytic capacitor between the Voltage-In pin, and the ground line to protect against any surges on the line, and to smooth the DC going in to the regulator .

STAGE#1: The Microphone and the Amplifier

As you can see from the picture below, we have an electret microphone connected to the ground line, and to one end of a 10k resistor. The other end of the resistor is tied to the 5v line. When an audio sound is sensed by the microphone, it changes that audio signal into a voltage that emulates the tone picked up. We can use that noise, but first we have to condition it. To rid ourselves of the DC component, we AC-couple the signal using a coupling capacitor. This signal will be extremely small, so we must first amplify it. We are going to do that using a handy-dandy LM324 quad op-amp IC.

The pull-down resistor to the right of the coupling capacitor is necessary for the operation of the non-inverting amplifier stage to work. In fact, all components in the below diagram are critical. The way a non-inverting op-amp works, is it takes two values ​​RA, which is the 1k resistor connected to the (-) input and ground, and RF (100k potentiometer), which is the feedback resistor, which is connected between the (-) input, and the output, and creates a voltage gain factor. The voltage gain factor (AV) is a multiplier. Once we determine the AV, we multiply the voltage at the input by the AV, and we have our output voltage. The 100k pot is used to vary the voltage gain. This will either increase the sensitivity or decrease the sensitivity of the circuit. The equation for AV = RF/RA in a non-inverting amplifier circuit.

STAGE#2 The Comparator:

The standard MCU does not like to work with sine waves, or any odd shaped wave. That is, unless you are using the ADC, which we are not. We want to turn our now amplified waveform into a 0-5VDC square wave that can be used by the PIC10F222. What are going to emply here is the comparator circuit. A comparator does exactly as you'd think. It compares voltages. If the voltage at the (-) input is higher than the voltage at the (+) input, then the output will be 0v. If the voltage at the (+) input is higher than the voltage at the (-) input, then the output will be 5v.


We have a resistor voltage divider network at the negative (-) input. Thiswill keep a constant 1.5v at the negative input. When a loud sound is generated and amplified to a voltage higher than 1.5v, then the output will go from 0-5v until the voltage at the (+) falls below 1.5v. We only need for the output of the comparator to be high for a micro second or so, so don't worry too much about the time duration of the output of the comparator being high.

THE BRAIN (PIC10F222):

Ah the good ol' archiac PIC10F222. This chip has an on-board internal oscillator, which exterminates any necessary external driving hardware, such as a crystal oscillator. We really only need 5v, Ground, the output of the comparator, and an I/O port deduced to control the driving of the relay. So we are only using 4 out of the 8 pins. Read the software section to see how the chip is interpreting the comparator information, and how the algorithm is set up.

The Relay Switch:

In order to drive our 5v relay using the output of a PIC, we have to set up a driver circuit, which in this case is a simple NPN transistor, and a diode. The diode does nothing to drive the relay, but it acts to protect the relay coil from surges. Any coil such as this should always be protected by a diode. The 1N4004 is as good as any. The base of the transistor is protected by a 10k ohm resistor. You want to make sure that you are using this, or else you will over-drive your transistor. When GPIO,0 outputs 5v (high or set), then the base of the NPN transistor is activated, allowing 5v to pass through the internal coil of the relay, and thereby creating a magnetic field that toggles the internal switch. When GPIO,0 is cleared (0v), then the transistor is deactivated, and the path from 5v to ground along the coil stops dead. The magnetic flield then collapses, and the relay switches back to default state. In other words, if you use the configuration below, you have 5v at the common wiper of the SPDT (Single pull double throw) relay. In default setting, the wiper is connected to the NC (Normally connected) pin of the relay. When the relay is activated, the wiper connects to the NO (Normally open) pin of the relay, and power is applied to the LED. When the relay is deactivated, the wiper re-connects to the NC pin, and the path from 5v to the LED is broken.

I have done my best to comment out this program as best as I could. You should be able to follow along. It is no masterpiece, but again, I was working with an inferior instruction set. You can download the .ASM code and use it with your PIC ICD2 programmer puck, as seen in the image. I am also happy to answer any questions you may have related to the software!

No comments:

Post a Comment

Post Top Ad

Pages