Sound-Activated Switch

Made by Karan Naik

Found in DioT 2019: Augmented Objects · UNLISTED (SHOWN IN POOLS)

Create an IoT enabled product that allows a user to switch a light on or off through sound



The goal of this project was to create a switch that is able to toggle on and off if sound above a certain level is detected.  

The motivation for this project came after a conversation with my father who is always at the fact that lights are on all over the house, mostly because once a family member hits the bed, he or she isn't willing to get up and turn the switch off. I wanted to design something that would ease this supposed nuisance. 



What I wanted to do is simply create a device that takes an easy gesture to activate it. Considering that lights switches in most homes are close to beds, I figured it would be easy to simply devise that activated with a simple clap. So if a user forgot to switch off a light, he/she could just clap and set if off. 

I did, however, realize that the switch could go off at just about any loud sound that went past the threshold level.  So I added in a button through which I could switch the sensor on and off, depending on when he or she entered the room. 



The process here is quite simple - all I had to do was identify the parts involved. 

Besides the obvious Argon development kit, I understood I needed a microphone, and part to actually switch the circuit on and off. I decided to use a servo for the latter, which is easy to connect and code. Finally, I used a simple tactile push-button to set the system ON or OFF. 

Initially, the servo kept going off as the sound threshold was too low. So I then updated the code to only detect sounds above a high value of 3000.  

Because the switch only activates in two directions, it made sense to turn the servo from 0 to 180 degree - essentially ON & OFF.  

The code for the entire project can be viewed below

int audiosense = A5;
int servopin = A4;
int pulse = 1000;
int value;
int button = D2;

Servo servo;
int sPos = 0;

void setup() {
    servo.attach( servopin );

void loop() {
    int state = digitalRead(button);
   if (state == HIGH){
    value = soundDetect();
    if (value > 3000)
        if( sPos == 0 )
            servo.write( 180 );
        sPos = 180;
        delay( 1000 );

        if( sPos == 180 )
            servo.write( 0 );
        sPos = 0;

int soundDetect() {     //when soundDetect is call this is what is run
    return analogRead(audiosense);     //this takes a reading from the audioSensor pin
Click to Expand


The final circuit components needed for this are: 

- Argon

- Breadboard

- Electret Microphone Amplifier - MAX9814 with Auto Gain Contro

- Micro Servo ( Adafruit Product ID: 195 )

- Tactile Pushbutton

- Jumper Cables

A video of the IoT device can be seen below


Next Steps

A logical next step would be to encase this circuit into a box that can be retrofitted onto existing switch panels. An added but useful feature would be to switch from sound to an app-controlled signal, so the input signal can be guaranteed to come from one source. 



Ideally, I would have liked a smarter device, and with an ambient display that reminds users to turn the switch on or off, instead of clapping all the time. For my next creative project, I would like to scope this out better and take into account the readings and what we've learned in class so far, and create a better object. 


Reference and Acknowledgments

Without a doubt, this wouldn't have been possible without Professor Daragh and our amazing TAs. 

Additionally, I was able to refer to projects and code from Hackster and leverage off several projects that have been done before. 

Share this Project

This project is only listed in this pool. Be considerate and think twice before sharing.


49713 Designing for the Internet of Things

· 18 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.


Create an IoT enabled product that allows a user to switch a light on or off through sound


February 1st, 2019