10% Off For Your First Order, Code:Elephant10

Arduino Project: Sound-control Light

Posted by Fiona Su on


In this experiment, we use sound passing through MIC to control the on and off of the light.
Hardware Required:

  • Arduino Board *1
  • USB Cable *1
  • Potentiometer *1
  • Highly Sensitive MIC *1
  • Red M5 LED *1
  • 220Ω Resistor *2
  • Breadboard *1
  • Breadboard Jumper Wire*5

Connection for REV4:


Connection for Arduino Mega 2560 R3:


The Connection Diagram for this experiment is relatively simple. It has no processing of the signal from the MIC, so signal is weak and insensitive. Instead of sound signal, we blow air to the MIC.
Sample Code:

int LEDpin = 7;                 // set pin for LED 
void setup() {
void loop() {
  int Soundvalue = analogRead(A0);  // read the input analog value
   digitalWrite(LEDpin,HIGH);      // when the analog value is bigger than the set value, turn on the LED
   for(int i=0;i<5;i++){
   delay(1000);                    // wait for 5s
   digitalWrite(LEDpin,LOW);      // turn off the LED 

Program description:
By rotating the potentiometer, the analog value of A0 changes; After adjusting the potentiometer, blow air into the MIC, and observe data in the serial monitor.
For example, the displayed data is less than 300 before blowing; after blowing, data is more than 700. Setup code if (Soundvalue > 700), control the on and off of the light; the on time of the light is controlled by the code for(int i=0;i<5;i++) { delay(1000); }, so the light is on 5*1s.
Connect the wire according to the connection diagram. 

Rotate the potentiometer to adjust the LED to a state where it’s between on and off.


When the light is out, data as shown in serial port monitor as pic 1; when clapping hands, light is on for 5 seconds and data as shown in pic 2.


Pic 1


Pic 2


Leave a comment

Please note, comments must be approved before they are published