Clap switch is popular since our childhood in the days of ’90s when basic electronic components were not so easily available and cost was not really towards cheap. Here is how to develop clap switch using Arduino Uno and microphone with circuit diagram, list of components and code. It is a basic project and also our second project with microphone. The previous project with microphone was a sound meter with LED.
Microphone is a transducer, which can sense sound and convert sound energy to electrical pulse. So microphone is a sensor too. We can use sound to change voltage. Microphones used in electronics works has two terminals – positive and negative. Polarity can be detected using a multimeter like diode testing mode.
Clap Switch Using Arduino Uno And Microphone
For this project, we need the following basic electronic components to build the clap switch, which are optional are pointed :
---
- Microphone
- 10k resistor
- 100k resistor
- 220 ohm resistor
- 100n capacitor
- LED
- Arduino Uno (or compatible board)
- Breadboard (optional, you can join on anything)
- Jumper wires (optional, you can use copper wire)
Here is the circuit :
Here is the code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | void setup() { Serial.begin(9600); pinMode(2, OUTPUT); } void loop() { int my_val; static bool led_state = false; my_val = analogRead(A2); if (my_val > 10) { if (led_state) { led_state = false; digitalWrite(2, LOW); Serial.println(my_val); } else { led_state = true; digitalWrite(2, HIGH); Serial.println(my_val); } delay(50); } } |
When you will upload and first use the code, open the Serial monitor on Arduino IDE on your computer for debugging. my_val
is my variable read from A2 input, which is microphone. I have set it an arbitrary value of 10. You can change it. If my_val
is > 10 then do not light up LED else light up the LED.
Inside the microphone there is transistor. Upon sound, microphone will pick up the sound and voltage will reach the analog pin which is read by Arduino. After reading our action is lighting up LED in this example.
Tagged With clap switch microphone , clap switch using arduino , arduino microphone , clap switch using arduino pdf , подключение микрофона к ардуино напрямую , circuit switch microphone , arduino и микрофон без модуля , arduino relayswitching with microphone , arduino microphone circuit , arduino clap switch using computer mic