<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>microphone Archives | Microcontroller Tutorials</title>
	<atom:link href="https://www.teachmemicro.com/tag/microphone/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.teachmemicro.com/tag/microphone/</link>
	<description>Microcontroller Tutorials and Resources</description>
	<lastBuildDate>Fri, 13 Oct 2023 04:48:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>

<image>
	<url>https://www.teachmemicro.com/wp-content/uploads/2019/04/blue-icon-65x65.png</url>
	<title>microphone Archives | Microcontroller Tutorials</title>
	<link>https://www.teachmemicro.com/tag/microphone/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Clap Switch for RGB LEDs using Arduino</title>
		<link>https://www.teachmemicro.com/clap-switch-rgb-led-arduino/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=clap-switch-rgb-led-arduino</link>
					<comments>https://www.teachmemicro.com/clap-switch-rgb-led-arduino/#respond</comments>
		
		<dc:creator><![CDATA[Roland Pelayo]]></dc:creator>
		<pubDate>Mon, 17 Feb 2020 04:10:55 +0000</pubDate>
				<category><![CDATA[Arduino Projects]]></category>
		<category><![CDATA[microphone]]></category>
		<category><![CDATA[rgb]]></category>
		<category><![CDATA[sound]]></category>
		<guid isPermaLink="false">https://www.teachmemicro.com/?p=4265</guid>

					<description><![CDATA[<p>Introduction This week’s Arduino project is a classic one and ideal for beginners. Here I will be showing how to build a simple clap switch for an RGB LED strip. Basically, a microphone captures the sound of the clap and converts it to a voltage. The Arduino processes that voltage and then changes the color &#8230;</p>
<p>The post <a href="https://www.teachmemicro.com/clap-switch-rgb-led-arduino/">Clap Switch for RGB LEDs using Arduino</a> appeared first on <a href="https://www.teachmemicro.com">Microcontroller Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3><strong>Introduction</strong></h3>
<p>This week’s Arduino project is a classic one and ideal for beginners. Here I will be showing how to build a simple clap switch for an RGB LED strip. Basically, a microphone captures the sound of the clap and converts it to a voltage. The Arduino processes that voltage and then changes the color of the RGB LED strip.</p>
<h3><strong>What You’ll Need</strong></h3>
<ul>
<li>Arduino <a href="https://www.win-source.net/category/integrated-circuits-ics/embedded/embedded-microcontrollers">Microcontroller</a> (<a href="https://s.click.aliexpress.com/e/_skx2d3">Nano</a> in this case but <a href="https://s.click.aliexpress.com/e/_sKPsMD">UNO</a> is possible too)</li>
<li><a href="https://s.click.aliexpress.com/e/_sDKbNr">Microphone breakout board</a></li>
<li><a href="https://s.click.aliexpress.com/e/_rQz7wD">Connecting wires (jumper)</a></li>
<li><a href="https://s.click.aliexpress.com/e/_sT31pB">RGB LED strip (12V)</a></li>
<li>3 x <a href="https://s.click.aliexpress.com/e/_smtTBL">2N2222A NPN Transistor</a></li>
<li><a href="https://s.click.aliexpress.com/e/_srmVID">12V power source</a></li>
</ul>
<h3><strong>Wiring Diagram</strong></h3>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2020/02/arduino-clap-switch-RGB_bb-2.jpg"><img decoding="async" class="aligncenter size-large wp-image-4268" src="https://www.teachmemicro.com/wp-content/uploads/2020/02/arduino-clap-switch-RGB_bb-2-1024x464.jpg" alt="Arduino clap switch for RGB " width="640" height="290" srcset="https://www.teachmemicro.com/wp-content/uploads/2020/02/arduino-clap-switch-RGB_bb-2-1024x464.jpg 1024w, https://www.teachmemicro.com/wp-content/uploads/2020/02/arduino-clap-switch-RGB_bb-2-300x136.jpg 300w, https://www.teachmemicro.com/wp-content/uploads/2020/02/arduino-clap-switch-RGB_bb-2-768x348.jpg 768w, https://www.teachmemicro.com/wp-content/uploads/2020/02/arduino-clap-switch-RGB_bb-2.jpg 1563w" sizes="(max-width: 640px) 100vw, 640px" /></a></p>
<p>The condenser microphone converts sound to an analog voltage. My <a href="https://www.teachmemicro.com/arduino-microphone/">Arduino microphone tutorial</a> covers the basics of how condenser microphones work. The voltage from the microphone is read by the <a href="https://www.teachmemicro.com/arduino-sensor-tutorial/">ADC</a> of the Arduino and converted it to a digital value.</p>
<p>You can use the <em>analogReadSerial</em> sketch (<em>File&gt; Examples&gt;Basics</em>) first to know the value of your clap sound. After that, replace the value of the threshold variable in the sketch below.</p>
<p>This clap switch project listens to three claps 1 second apart. When this condition is met, the RGB LED strip changes color. Moreover, the sequence of colors follows R-O-Y-G-B-V.</p>
<p>A particular LED turns on when the voltage drop across it is zero. For example, a high pulse from Arduino's D9 will turn on the transistor resulting in the green LED turning on. The 2N2222A transistor in this project was enough to handle the current requirements of the LED strip.</p>
<p>You can use a 5V or a 12V LED strip as long as you have the power source for it. My diagram uses a 12V LED strip so I needed to have a separate supply for the Arduino board.</p>
<h3><strong>Sketch/Code</strong></h3>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-cpp" data-lang="C++"><pre><code class="language-cpp">/*
 * Clap Switch for RGB LEDs using Arduino
 * 
 * by: R. Pelayo
 * Created: February 13, 2020
 * 
 * Full project tutorial on: teachmemicro.com/clap-switch-rgb-led-arduino
 */

#define threshold 200  //change this according to your clap sound
int red = 10;
int green = 9;
int blue = 11;
int mic = A0;
int sound_value;
int clap_counter = 0;
int color_counter = 0;

void setup() {
  pinMode(red,OUTPUT);
  pinMode(green,OUTPUT);
  pinMode(blue,OUTPUT);
}

void loop() {
  int sound_value = analogRead(mic);
  if(sound_value &gt; threshold){
    clap_counter++;
    if(clap_counter &gt; 2){
      clap_counter = 0;
      color_counter++;
      if(color_counter &gt; 5) color_counter = 0;
      changeColor();
    }
  }
  delay(1000);
}

void changeColor(){
  switch(color_counter){
    case 0: //display red
      analogWrite(red,255);
      analogWrite(green,0);
      analogWrite(blue,0);
    case 1: //display orange
      analogWrite(red,210);
      analogWrite(green,100);
      analogWrite(blue,0);
    case 2: //display yellow
      analogWrite(red,255);
      analogWrite(green,255);
      analogWrite(blue,0);
    case 3: //display green
      analogWrite(red,0);
      analogWrite(green,255);
      analogWrite(blue,0);
    case 4: //display blue
      analogWrite(red,0);
      analogWrite(green,0);
      analogWrite(blue,255);
    case 5: //display violet
      analogWrite(red,255);
      analogWrite(green,0);
      analogWrite(blue,255);
  }
}</code></pre></pre>
</div>
<p>Here, I set the threshold value to 200. Every time the voltage from the microphone reaches this level, a variable (<em>clap_counter</em>) increments. When this variable reaches a value of three, the function to change color is invoked, and another variable (<em>color_counter</em>) increments. The <em>color_counter</em> variable is used for knowing which color in the sequence to be displayed.</p>
<p>&nbsp;</p>
<p>The post <a href="https://www.teachmemicro.com/clap-switch-rgb-led-arduino/">Clap Switch for RGB LEDs using Arduino</a> appeared first on <a href="https://www.teachmemicro.com">Microcontroller Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.teachmemicro.com/clap-switch-rgb-led-arduino/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: www.teachmemicro.com @ 2026-08-26 03:48:49 by W3 Total Cache
-->