Introduction: Stop Rants With the Rant Buddy
In my home we find a lot to complain about: The bus was late, the water cooler at work isn’t cold enough, the deli closed early. But left unchecked, these minor grumbles can spiral into full-blown rants.
That’s where this handy rant-stopper comes in: Help your friends and loved ones by cutting it off before they become unhinged.
If you sense someone losing their sense of perspective, turn on the rant-stopper! One push should bring them back down and hopefully help them laugh it off.
In this demo I'll show you how to make your own customized rant stopper. I'm using the Curb Your Enthusiasm theme song (Frolic) and the World's Tiniest Violin song (Woe is Me), but you can modify the code to use any song at all!
Step 1: Tools & Materials
Materials - For Small Version:
- Enclosure size M522
- 3.3V Pro Micro or 3.3V Mini Trinket
- Momentary Push Button or Toggle Switch
- Coin Battery Holder
- 3v Coin Battery
- Extra wires, heat shrink, solder Tape
Materials - For Medium Version:
- Enclosure size M530
- Any 5v Micro-controller (Such as Arduino Pro Mini, Pro Micro, Teensy, Adafruit Feather)
- Momentary Push Button or Toggle Switch
- Battery Holder
- 5v DC Converter (Optional - only needed if your micro controller doesn't have a 5v voltage regulator)
- 9V Battery
- Extra wires, heat shrink, solder Tape, foam and a rubber band
Step 2: Test the Arduino Speaker Melody
Start by playing the most basic melody with your microcontroller and speaker.
Open the Arduino Software and make sure it’s set up to program your microcontroller. If you’ve never programmed your board before, check the instructions from your microcontroller before you continue.
Look at the pinout diagram that came with your microcontroller and identify one ground pin, and one PWM pin. You will hook these two pins up to our speaker. The ground pin should connect to the negative (-) side of your speaker, and the PWM pin should connect to the positive (+) side of your speaker. Note the corresponding number that your PWM pin is assigned to; in my example I’m using a Teensy 2.0++ and connecting to PWM pin #26.
The Arduino software comes out of the box with a whole bunch of helpful examples. Open the sound example by going to File -> Examples -> 02. Digital -> toneMelody. Looking at the source code, on line 37 you’ll see the function call “tone(8, melody[thisNote], noteDuration);” and on line 44 you’ll see the function call “noTone(8);” On these two lines, replace the number 8 with the PWM pin you’re using. So for me this would become “tone(26, melody[thisNote], noteDuration);” and “noTone(26);” respectively.
Then click the “upload” arrow button to put this code on your arduino. You should hear a basic demo melody playing through your speaker.
Step 3: Customize the Song
Now that you have sound coming out of the speaker, customize the song to fit your ranter. In our house, the Curb Your Enthusiasm theme song and the World’s Tiniest Violin will usually stop a rant in its tracks, so those are the two songs I’ll use in this example.
Find the sheet music for the song you want to use through Google. (And if you need to brush up on your sheet music reading, check out this tutorial.)
You’ll be editing the "melody” array on line 22 and the “noteDurations” array on line 27 from the previous example to make our own song. For each note in your song, determine the corresponding note in the pitches.h file, as shown in the screenshot above. Add this note to the “melody” array, and the duration of the node in the “noteDurations” array, and increase the total number of notes on line 32.
You can download the source code to a couple examples here:
Step 4: Hook Up the Whole Circuit
Now that you have your song playing on the micro-controller, let’s replace USB connection to your computer with power from a battery.
You’ll be powering the micro-controller with a battery, and placing a momentary or toggle switch between the battery and the micro-controller. That way when the switch is not engaged, the micro-controller is off, and when the switch is engaged, power flows through from the battery to the micro-controller.
If you are using a micro-controller that takes 5V with a 9V battery, and your micro-controller doesn't have a voltage regulator, then you will also want to use the 5V step-down converter, which will turn the 9V from the battery into 5V for the micro-controller. Hook the converter up between the switch and the power side of the battery, as shown in the image above. (If you're using the 3.3V micro-controller with the 3V battery then you can skip this piece.)
Hook up the whole circuit with a breadboard and alligator clips to ensure that it works properly. The music should start as soon as you flip the switch, and turn off when you flip the switch back.
Step 5: Prepare the Enclosure
Now that you have the entire circuit working, make sure all the components and wires fit in the enclosure. You may have to trim down some of the wires to make sure it fits completely.
With the components roughly placed in the enclosure, mark two small dots where the positive and negative speaker wires should go through the enclosure, and mark one large dot where the button should go through the enclosure.
Before you drill holes in the enclosure, a couple notes:
- I highly, highly recommend using plastic drill bits for these holes. I tried to drill with normal drill bits and you can see in the second picture what happened -- the enclosure cracked every single time.
- Place the enclosure on a wood surface that is safe for drilling -- as in it’s okay if you accidentally drill a hole in it.
- And as always, safety goggles and a respirator to keep debris out of your eyes and lungs.
Now drill your three holes carefully!
Step 6: Final Wiring
Now that you have your enclosure ready, it’s time to do the final wiring of the circuit with solder and heat-shrink.
Trim down your wires as short as necessary so they fit in the container. When connecting two wires, I like to:
- Trim a small piece of heat shrink and place it on one of the two wires.
- Twist the two wires together.
- Solder the woven joint together with a small amount of solder. (As always, wear safety goggles, a respirator and use good ventilation when soldering!)
- Cover up the soldered joint with heat shrink. Heat the heat-shrink with the heat gun to seal it in place.
You should now have a fully functional circuit that is ready to be placed in the enclosure!
Step 7: Put It All Together
First mount your switch to the big hole you made in the enclosure. Then weave the two speaker through the two small holes you made in the enclosure.
Delicately fit the rest of the circuit into the enclosure, possibly using foam or a rubber band to keep the circuit compact and stable.
Step 8: Go Forth and Stop Rants!
Participated in the