Sound Decibel Multicoloured LED Indicator
by JeanC117 in Circuits > Audio
2681 Views, 9 Favorites, 0 Comments
Sound Decibel Multicoloured LED Indicator
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
- Arduino Uno
- Sound detector board
- RGB LED
- 3 pieces of 100Ω resistors
- Breadboard
- Jumper Cables
Connecting the Sound Detection Board to the Arduino
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
- 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.
- Connect the ground pin of the RGB LED (longest pin) to the GND pin of the Arduino using a jumper wire.
- Connect the remaining three pins to three 100Ω resistors each which then connects to the Arduino's digital pins 4, 6 and 9.
- 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
//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
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.