Sound Decibel Multicoloured LED Indicator

by JeanC117 in Circuits > Audio

2684 Views, 9 Favorites, 0 Comments

Sound Decibel Multicoloured LED Indicator

2016-07-22 14.47.15.jpg
2016-07-22 14.44.03.jpg

Sound sensors can be used for a variety of things, for example, turning lights off or on by clapping, or driving an LED to the beat of your favourite song.

This project will be using the Sound Detector Board as to provide feedback to the user about the decibel level of a room. Whether you have a loud neighbour, crying baby, or simply want to protect your ears, this simple RGB sound level indicator will provide a visual feedback to the decibel level of the surrounding environments.

Tools and Materials

2016-07-22 13.47.57.jpg

Connecting the Sound Detection Board to the Arduino

2016-07-22 14.43.20.jpg

The envelope output allows you to easily read amplitude of sound by simply measuring the analog voltage. Gain can be adjusted with a through-hole resistor, to change the threshold of the binary (gate) output pin as well. Check the hookup guide below for more information about setting gain.

Connecting the RGB LEDs to the Arduino

2016-07-22 14.43.07.jpg
Screen Shot 2017-07-28 at 1.41.03 AM.png
  1. Connect the envelope pin of the sound sensor to the analog pin 0 of the Arduino. This will be the indicator of the sound level as it analyzes the sound waves amplitudes.
  2. Connect the ground pin of the RGB LED (longest pin) to the GND pin of the Arduino using a jumper wire.
  3. Connect the remaining three pins to three 100Ω resistors each which then connects to the Arduino's digital pins 4, 6 and 9.
  4. Wire the power to the sound board by connecting the 3.3V pin and GND pin from he Arduino to the sound detector board. Note that the Arduino have multiple ground pins and they are all common to each other.

Coding

Screen Shot 2017-07-28 at 1.41.55 AM.png
//pin variables
const int redPin = 4;
const int greenPin = 6;
const int bluePin = 9;
const int soundPin = 0;
//variables for storing raw sound and scaled value
int sound;
int scale;
void setup()
{
 //start the serial port a@ 9600bps
 Serial.begin(9600);
 //set RGB pins to OUTPUT
 pinMode(redPin, OUTPUT);
 pinMode(greenPin, OUTPUT);
 pinMode(bluePin, OUTPUT);
}
void loop()
{
 //read and store the audio from Envelope pin
 sound = analogRead(soundPin);
 //map sound which in a quiet room a clap is 300
 //from 0 to 3 to be used with switch case
 scale = map(sound, 0, 300, 0, 3);
 //print values over the serial port for debugging
 Serial.print(sound);
 Serial.print("   ");
 Serial.println(scale);
 //switch case on scaled value
switch (scale)
{
//if 0 RGB = Blue
case 0:
   digitalWrite(redPin, LOW);
  digitalWrite(greenPin, LOW);
  digitalWrite(bluePin, HIGH);
  break;
//if 1 RGB = Green  
case 1:
  digitalWrite(redPin, LOW);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, LOW);
  break;
//if 2 RGB = Yellow  
case 2:
  digitalWrite(redPin, HIGH);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, LOW);
  break;
//if 3 RGB = Red
case 3:
  digitalWrite(redPin, HIGH);
  digitalWrite(greenPin, LOW);
  digitalWrite(bluePin, LOW);
  break;
//default off
default:
  digitalWrite(redPin, LOW);
  digitalWrite(greenPin, LOW);
  digitalWrite(bluePin, LOW); 
  break;
 }
}

Sound Level Demonstration

2016-07-22 14.46.00.jpg

My room was very quiet at the time that this picture was taken, so the LED colour that was shown in blue. The louder it gets, such as music playing in the background or clapping changes the colour to green.