Quick Guide On How Ambiance Light Works With Sound Sensor

With smart home and automation, we need to sense the intensity of light in many appliances. Here we explain a simple implementation of ambient light to sound sensor.

Quick Guide On How Ambiance Light Works With Sound Sensor

In this tutorial, you will learn how ambient light works with sound sensors. To design this system, let’s start with the basic requisites of Arduino’s working. Wondering what Ambient light sensors is? Well, Ambient light sensors are mechanisms that strive to maximize both energy conservation and visual quality in any electronic device. Let’s get started with the setup:

Introduction:

I innovate Dj lights at Home. Dj lights are the lights that turn on/off, majorly these are controlled lights based on the intensity of song beat or bass. Here I use Arduino, sound detection sensor, and RGB instead of light.

Arduino:

  • Arduino is an open-source electronics platform based on easy-to-use hardware and software.
  • Arduino boards are able to read inputs – light on a sensor, a finger on a button, or a Twitter message – and turn it into an output – activating a motor, turning on an LED, publishing something online
Quick Guide On How Ambiance Light Works With Sound Sensor

Sound Detection Sensor:

  • The image below detail the controls,pinout and key components of sound detection sensor
Sound Detection Sensor:
  • The Sound Detection sensor module has a built-in capacitive electret microphone which is highly sensitive to sound
  • Sound waves cause the thin film of the electret to vibrate and then the capacitance changes, thus producing the corresponding changed the voltage, so it can detect the sound intensity in an ambient environment.
  • Since the change is extremely weak, it needs to be amplified.
  • We use an LM393 as the power amplifier here.
  • You can adjust the sensitivity with by adjusting the Potentiometer
  • When the sound level exceeds the setpoint, an LED on the sensor module is illuminated and the output is sent low
  • When referring sensitivity, well. I mean:
    • When less sensitive, it takes more sound to trigger the device
    • When more sensitive, it takes less sound to trigger the device

RGB

  • RGB LED module LED is made from a patch full color, by R, G, B three-pin PWM input voltage can be adjusted in three primary colors (red/blue/green) strength in order to achieve the full-color mixing effect.
  • Can interface with a variety of microcontrollers
RGB
  • Operating voltage: 5V
  • Current Resistance : 50mΩ
  • LED drive mode: common cathode drive
  • Dimension: 19 x 15 mm

Arduino and sound detection sensor pin connection:

ArduinoSound detection sensor
Pin 6D0
A0A0
5VVCC
GNDGND

Arduino and RGB LED pin connection:

Arduino RGB LED
Pin 8 B pin
Pin 9 R pin
Pin 10 G pin
GND – pin
After all the connection connects Arduino using USB with your pc. Upload the given below code into Arduino.
int sensorPin=6;
int led_G = 10;
int led_R = 9;
int led_B = 8;
int analogPin = A0;
void setup()
{
  Serial.begin (9600);
  pinMode(sensorPin, INPUT);
  pinMode(led_G, OUTPUT);
  pinMode(led_R, OUTPUT);
  pinMode(led_B, OUTPUT);
}
 
void loop()
{  
  int val = analogRead(analogPin);
  int sensorpin = digitalRead(sensorPin); 
  Serial.println(sensorpin);
  if (val>=530 && val<=694) 
    { 
          analogWrite(led_B,0); 
          analogWrite(led_R, 128); 
          analogWrite(led_G, 255); 
    } 
   else if(val>=695 && val<=859) 
    { 
       // analogWrite(led_R, 255); 
          analogWrite(led_G,0); 
          analogWrite(led_R, 175); 
    } 
   else if(val>=860 && val<=1024)
    {
       //  analogWrite(led_R,255);
           analogWrite(led_R,255);
           analogWrite(led_G,0);
    }
   else
    {
           analogWrite(led_R,0);
           analogWrite(led_B,0);
           analogWrite(led_G,0);
    }
} 
  • Adjust the sensitivity of the sound sensor using a potentiometer. As you preferred sensitivity adjust it. I preferred here 530 or 525.
Sound Detection Sensor:
  • Adjust the sensitivity of the sound sensor using a potentiometer. As you preferred sensitivity adjust it. I preferred here 530 or 525.
And now, play a song with some solid down beats and have fun watching your Ambient light dance to the music!

Demo Video: