Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Harsh Jee
Published

Sound Sensing Lights for Home automation

Sound sensing LEDs, can act as a music synchronizer or as an automated light for the room which turns on when someone claps or pinches.

BeginnerFull instructions provided1 hour652
Sound Sensing Lights for Home automation

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
LED (generic)
LED (generic)
×10
Sound Detection Sensor Module for Intelligent Vehicle Arduino Compatible
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 221 ohm
Resistor 221 ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Code for sensing analog signals

Arduino
This code is for sensing analog signals, Here sensor will react to the alternating sound signal, when pitch is high, or low. Basically LED will work as a dimmable LED for sound signals.
int anasound= A0;
int anaval;       
float ledbright;
int led=9;

void setup() {
  // put your setup code here, to run once:
pinMode(anasound,INPUT);
pinMode(led,OUTPUT);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
anaval=analogRead(anasound);
delay(200);
ledbright=(255./1000.)*anaval;
analogWrite(led,ledbright);
if(ledbright>255){
  ledbright=255;
}
Serial.print("Ledval= ");
Serial.print(ledbright);
Serial.print(" ");
Serial.print("sound sensor= ");
Serial.println(anaval);
delay(200);
}

Code for sensing digital signals

Arduino
This code is for sensing digital signals, like when sensor will hear a sound it will turn high once and will stay in same state until it hears a sound signal again which will get the sensor to active low state.
int digsound= 7;
int digval;
int ledbright=0;
int led=9;

void setup() {
  // put your setup code here, to run once:
pinMode(digsound,INPUT);
pinMode(led,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
digval=digitalRead(digsound);
if(digval==1){
  if(ledbright==0){
   digitalWrite(led,HIGH);
   ledbright=1; 
  }
  else{
    digitalWrite(led,LOW);
    ledbright=0;
  }
}
}

Credits

Harsh Jee
3 projects • 1 follower
Electronics Engineer | super interested in VLSI and semiconductor industry.
Contact

Comments

Please log in or sign up to comment.