Introduction: Sound Pulsing Switch
Ever have the problem when you staying on bed, but suddenly realise that the lights are still on. However, you are so tired that you do not want to walk down the bed to turn off the lights, nor spending eighty dollars to buy a Philip Hue ambient light, which would allow you to turn off the lights using your phone. If you are using a traditional light with a switch, why not check out this novel, yet easy Arduino project to resolve your laziness!
I started to have the idea of this project at approximately a year ago, when I moved to my new home, finding out that my light switch is nowhere near my bed, forcing me to leave my bed every night when I laid on my bed tiring, just for TURNING THE LIGHT OFF (which irritates me every night)! However, after doing this project, I have been benefited massively throughout, and hope to share this idea to all INSTRUCTABLE users, who currently also suffers under the far light switch issue.
The basic idea of this Sound Pulsing Switch is to trigger the KY-037 Sound Detector Sensor for doing a set of actions, including to turn on the servo motor for hitting the actual light switch in order to turn it off. So, how exactly does the KY-037 Sound Detector Sensor work: basically, it detects the intensity of sound in the environment, in this case, every 20 milliseconds (this can be set in the coding section, step 5), and when it finds out an unusually loud soundwave in its Oscilloscope Trace, it will then trigger the count, whereas when it reaches two counts, it will then activate the servo motor, further turning off the lights.
Step 1: Supplies
In order to create this Sound Pulsing Switch, we need certain supplies such as in below:
- Arduino Nano board
- Jumper Wires (Female to Female & Female to Male & Male to Male)
- KY-037 Sound Detector Sensor Module
- Aluminum Electrolytic Capacitors 220uF 25V
- Servo Motor
- Battery Bank
- External Power Supply *(USB to two head Du-Pont Wire)
- 9V Battery
- 9V Battery Connector
Decorating Model Supplies:
- Cardboard (or wood, if doing laser cutting)
Step 2: Assemble the Electronic Components
Before actually constructing the model, we have to assemble the electronic components, which is very simple, and can be done in a few steps as such:
- Solder the 9V battery connector the Arduino Nano board. This might be a little difficult for people who are not familiar with any soldering techniques, but this is essential for succeeding to make this project because if the board is not supplied by enough power, it might not function properly or well. For soldering, connect the red wire to the VIN pin; and the black wire to the GND pin, which both stands on the right-hand side of the board.
- Connect the jumper wires onto the Arduino Nano board. In this project, we will only contribute to the A0, D2, the GND pin and the 5V pin.
- Using the breadboard to connect the pins, we need to connect the G pin from the KY-037 Sound Detector Sensor Module to the breadboard; on the same column (beware of this, if not on the same column, your final project would not function), connect the black wire from the servo motor, and the black wire from your external power supply (you need to do this for the GND pin but not the 5V pin because that the external power supply would need to make a common ground in case of not burning your Arduino), then connect another Male to Female jumper wire onto the same column and to your Nano respectively.
- Next, connect the “+” pin from the KY-037 Sound Detector Sensor Module to one of the holes on the same column, then take another Male to Female jumper wire connecting to the same column on the breadboard and the other side to the Nano board.
- After that, connect the red wire on the servo motor to another column despite the used ones, and place the red wire from the external power supply to the same column also, to power the battery bank. Indeed, connect the USB-sub head to the power bank in order to make it powering the servo motor.
- Also, crossing beyond the two columns where the GND and the 5V pin stand, place the capacitance’s two legs on both columns, to create a relatively stable environment for the KY-037 Sound Detector Sensor.
- Lastly, connect the white wire on the servo motor to the D2 pin on the Nano. And connect A0 to A0 from the KY-037 Sound Detector Sensor Module to the Arduino Nano board respectively.
And you are done with all the electronics!
Step 3: The Design of the Model
For this project, the model building is extremely easy, as we only have to create a box with six sides. However, the design had to be as certain as the AutoCAD file, I have provided underneath.
If you really want to make this project well and precise, continue reading to discover the design idea of this project.
This Sound Pulsing Switch contains a box, which has six sides, the holes on the sides each represented a space for placing the electronic components, as to make the device function.
- For the top, there is a hole of length 3 * width 2, for placing the servo motor, giving it space to function and hit the button;
- Next as the opposite bottom, we note that this is just a rectangle base, that contains no holes to hold everything in it nice and confirm; then for the right side, we need a hole for the external power supply wire to come out for connecting to the power bank in order to power the power bank;
- Afterwards, for the left-hand side, it looks identical to right left-hand side but without the hole;
- Lastly, for the front, we need actually more holes, one for the 9V battery connector to be out of the box, so that we can change the battery easily when we go out of power, as to switch off the switch to prevent any waste of battery power, the other is for the microphone of the KY-037, to ensure that the device could detect the change of the sound in the environment;
- Also as the bottom, the backside contains no holes, just to hold everything nice and affirm
Step 4: Building the Model
After we had made our plan thoroughly, we now will have to move onto the process of actually building up the model. However, this process will be extraordinarily easy compared to the previous step, as just do this:
- Cut out the six sides in the scale provided in the AutoCAD file with the cardboard or use laser cut
- Take the tacky glue and paste it on the sides of the pieces to assemble them together, but still leave the backside out that we could still arrange the components within it
- Stuck your 9V battery connector into the hole that we have cut in the front side of the model
- Stuck your KY-037 Sound Detector Sensor Module into the hole that we have cut, but remember to cut a little wider, the diameter I provided is an approximate value for "my" component, which might vary in different ones, also the rectangular part might hit the side, causing it not to be tucked well enough, be in mind
- Tear off the sticker behind your breadboard and stick it behind the front piece of your model
- Place your servo motor well into the hole that we had cut out on the top of the model
- Try to place some of the sticky clay behind the servo motor against the side to strengthen it
- Also, remember to put the double-sided tape to make it stronger
- Pull your external USB cable out of the hole we had cut out on the right-hand side of the structure, and connect it to the power bank
- Glue your backside onto the model, but if you are not certain about your work and might still need to arrange or repair your device, use some of the Scotch tapes to stick it first, that you could easily tear it off
Step 5: Coding
And nowhere is the fun yet most essential part in this project, without coding, your device would never work, not soever how good you had built up your model or the accuracy of making the circuit, without coding, this is nothing. So, down here, I wrote a code just for this project, and explained what every line means in the comment section in the code, that however, if anyone still has any problems, feel free to leave a comment underneath that I would be happy to reply instantly (I believe).
In this code, I chose to let the servo motor to turn ninety degrees and a hundred and eight degrees, however, this can be arranged due to the different switch everyone got at home, and I believe that this is free for all to be changed. While looking at my code, keep bearing in mind that this device is for "automatically" switch off the light using the method of sound, that please do not be confused, and if you are confused, feel free to refer back to the video at the very beginning. You can now see the code down below or through this Arduino Create Website link.
In addition, if enough people asked about any clarification of the code, I might think about it LOL...
Step 6: Completion
Now you have finished the project that you may now play with the Sound Pulsing Switch to turn off your light, indicating your laziness will never be an issue any more! And remember if you have done this project, share it online to me, and to the world, that to show the wonderfulness of the project!
Be curious, and keep exploring! Good luck!
Participated in the
Arduino Contest 2020