HeathenHacks
Published © GPL3+

Sound Sensor Activated LEDs with LCD for Sound Level Data!

Just a basic sound sensor activated LEDs with an optional LCD for sound level data. ***STROBE LIGHT EFFECT AT AROUND 8:45 MINUTE MARK!***

BeginnerFull instructions provided23,604
Sound Sensor Activated LEDs with LCD for Sound Level Data!

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
9V battery (generic)
9V battery (generic)
Optional.
×1
9V to Barrel Jack Connector
9V to Barrel Jack Connector
Optional.
×1
Male/Male Jumper Wires
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
I used the one with an i2c backpack.
×1
Sound Sensor Module KY-038
×1
5 mm LED: Yellow
5 mm LED: Yellow
×2
5 mm LED: Green
5 mm LED: Green
×4
5 mm LED: Red
5 mm LED: Red
×2
5 mm LED: White
×4
SparkFun 5 mm LED: Blue
×4
Resistor 100 ohm
Resistor 100 ohm
For the white and blue LEDs.
×8
Resistor 220 ohm
Resistor 220 ohm
For the red and yellow LEDs.
×4
Resistor 330 ohm
Resistor 330 ohm
For the green LEDs.
×4

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

I made this using Photoshop.

Just follow the wires from end to end.

Code

SoundSensorLEDwData

Arduino
I added comments on the code for some explanation. I hope I know what I'm doing. lol.
#include "Arduino.h"               
#include "LiquidCrystal_PCF8574.h"  

#define LCD_ADDRESS 0x27
#define LCD_ROWS 2
#define LCD_COLUMNS 16
#define SCROLL_DELAY 150
#define BACKLIGHT 255

LiquidCrystal_PCF8574 LCDi2C;

//Add name and position of the LED bulb on the breadboard + Where it's connected on the Arduino.
// LED1 is LED Bulb 1 on the breadboard and 3 is Digital PWM 3 on the Arduino.

int LED1=3;
int LED2=4;
int LED3=5;
int LED4=6;
int LED5=7;
int LED6=8;
int LED7=9;
int LED8=10;
int soundSensor=2; // Digital Pin 2 on the Arduino is where the "DO" of the Sound Sensor is connected.
int sensorValue = analogRead(A0); //This is where the "AO" of the Sound Sensor is connected.

boolean LEDStatus=false;

void setup () {

  Serial.begin(9600);
  LCDi2C.begin(LCD_COLUMNS, LCD_ROWS, LCD_ADDRESS, BACKLIGHT); //These are the ones that we defined earlier.
  pinMode(soundSensor,INPUT); //Because our Sound Sensor is an Input Device.
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED4, OUTPUT);
  pinMode(LED5, OUTPUT);
  pinMode(LED6, OUTPUT);
  pinMode(LED7, OUTPUT);
  pinMode(LED8, OUTPUT);
  pinMode(sensorValue, OUTPUT); //sensorValue is declared as an output because it will be printed on the LCD and Serial Monitor.
}

void loop() {
  int sensorValue=analogRead(sensorValue);
  int SensorData=digitalRead(soundSensor);
  if(SensorData=1){
    if(LEDStatus==false){
      LEDStatus=true;
      Serial.println(sensorValue); //This will be printed on the Serial Monitor just to make sure that the data on the LCD is the same.
        LCDi2C.setCursor(0,0);     //This is to make the text not scroll up and disappear then reapper again when sensorValue data is being added.
        LCDi2C.print("SoundLevel Data:");  //The text that will appear and stay on Row 1 of the LCD.
        LCDi2C.setCursor(0,1);     //This is to make the text not scroll up and disappear then reapper again when sensorValue data is being added.
        LCDi2C.print(sensorValue);  // The data that will appear on the LCD.
        LCDi2C.print("                ");  // This is to prevent extra digit from the past value appearing on current value. Like, when the past value is 1234, then the current is supposed to 619, but it appears as 6194.
    }
    
     if(sensorValue>=750) {         // sensorValue greater than or equal to XX. XX numbers are gathered from the most recent data on the Serial Monitor. Copied and pasted it on a spredsheet, then arranged from the lowest to the semi highest sound volume level.             
        digitalWrite(LED8,HIGH);    // You can use the different values from the sensor on each LED bulb if you want it to act like a sensor by displaying or lighting up corresponding LED bulbs according to the sensor values data.
    }                               // Like Yellow LED bulbs will light up when the sensor picks up a low volume sound aka. Minimum volume level, Green LED bulbs light up when the Volume level is OK, and Red LED Bulbs light up when the volume hits the Loud volume threshold.
      else{                         // Alternatively, you can just add the same value to all the LEDs if you want all of them to react at the same time. 
        LEDStatus=false;            // You can also play with the sensor values to make the LEDs dance. Rearranging the sensor values randomly for example. Or making 2 LEDs react at the same value and other LEDs react to other values.
        digitalWrite(LED8,LOW);
      }
     if(sensorValue>=735) {
         digitalWrite(LED7,HIGH);
    }
      else{
        LEDStatus=false;
        digitalWrite(LED7,LOW);
      }
     if(sensorValue>=725) {
         digitalWrite(LED6,HIGH);
    }
      else{
        LEDStatus=false;
        digitalWrite(LED6,LOW);
      }
     if(sensorValue>=720) {
         digitalWrite(LED5,HIGH);
     }
      else{
        LEDStatus=false;
        digitalWrite(LED5,LOW);
    }
     if(sensorValue>=715) {
         digitalWrite(LED4,HIGH);
     }
      else{
        LEDStatus=false;
        digitalWrite(LED4,LOW);
    }
  
     if(sensorValue>=700) {
         digitalWrite(LED3,HIGH);
     }
      else{
        LEDStatus=false;
        digitalWrite(LED3,LOW);
    }
      
     if(sensorValue>=675) {
         digitalWrite(LED2,HIGH);
     }
      else{
        LEDStatus=false;
        digitalWrite(LED2,LOW);
    }
      
     if(sensorValue>=650) {
         digitalWrite(LED1,HIGH);
     }
      else{
        LEDStatus=false;
        digitalWrite(LED1,LOW);
      }
    }
     else{
        LEDStatus=false;          //Not really sure why I added this. Lol.
        digitalWrite(LED1,LOW);
        digitalWrite(LED2,LOW);
        digitalWrite(LED3,LOW);
        digitalWrite(LED4,LOW);
        digitalWrite(LED5,LOW);
        digitalWrite(LED6,LOW);
        digitalWrite(LED7,LOW);
        digitalWrite(LED8,LOW);
    }
   }
   

Credits

HeathenHacks

HeathenHacks

24 projects • 57 followers
I don't know what I'm doing here.

Comments