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

0

Intention

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. 


0

Goal

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. 

0

Process

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

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

Servo servo;
int sPos = 0;

void setup() {
    pinMode(audiosense,INPUT);
    pinMode(servopin,OUTPUT);
    pinMode(button,INPUT_PULLUP);
    Particle.variable("soundvalue",value);
    
    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 );

    }else{
        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
0

Outcome

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

0

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. 

0

Reflection

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. 

0

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. 

x
Share this Project

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


Courses

49713 Designing for the Internet of Things

· 18 members

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


About

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

Created

February 1st, 2019