Introduction: Robot Party Drumkit
This is an Arduino/Processing controlled snare drum. Two servomotors control the drumsticks, and can either be controlled by keyboard input on an attached computer or by triggering an Ultrasonic sensor. As an added bonus, an Adafruit NeoPixel ring is attached to the back of the drum and illuminates the drum when triggered by the keyboard.
You will be able to control the drumsticks manually by pressing the "a" or "l" keys on your keyboard - doing so will also trigger the NeoPixel light show! You can control the drumsticks automatically by holding your hand in front of the Ultrasonic Sensor - hold it far away, and a simple pattern will be played, hold it close and the sticks will freak out!
This is a fun project that should be easy to extrapolate to further projects. Between the combination of constant snare drum chatter and flashing lights, this project is sure to grab the attention of anybody in the immediate vicinity.
For this project, you will need:
1 snare drum
1 broad, flat wooden board
3 roughly 8" long 2x4 pieces
2 drum sticks (shortened to roughly half length)
2 Arduino Uno boards
1 Adafruit Motor Shield (may not be necessary but we used one)
2 hobby servomotors (we used the TowerPro SG90 models)
1 Adafruit NeoPixel Ring
1 Ultrasonic Sensor (we used the HC-SR04)
Several plastic ties
Lots of double sided tape
Lots of wires
Step 1: Build the Base
First things first, we'll need to build the base for this project.
1. Attach two 2x4 chunks to the board: using a drill, screw L-brackets to either side of the 2x4 chunks, and then screw the brackets to the wooden board. Make sure the 2x4s are placed close enough to one edge of the board so that you will be able to attach servomotors/drum sticks to them and have the drum sticks reach the snare drum.
NOTE: If you have problems with this, a healthy dose of two-sided tape between bracket and wood will probably suffice. We didn't have short enough screws to properly attach the brackets to the wooden base, and we used two-sided tape instead successfully.
2. Place the final 2x4 chunk at the opposite end of the board.
NOTE: We didn't actually attach this particular 2x4 to the board, but should you want to, follow the above instructions!
Step 2: Assemble the Arduinos
Now we need to set up the meat of our project, the Arduino boards that actually allow all this to happen!
1. Attach the Adafruit Motor Shield to one Arduino board. Instructions for how to do this can be found here: https://cdn-learn.adafruit.com/downloads/pdf/adafr...
2. Set up the Ultrasonic Sensor. Using double sided tape and popsicle sticks, build a small stand for the sensor.
3. Attach the Ultrasonic Sensor to the Motor Shield. Connect VCC to 5V, Trig to pin 12, Echo to pin 11, Gnd to GND.
4. Attach the Servomotors to the Motor Shield. The Motor Shield has two special placements for Servomotors in one corner of it, next to the USB power/data input port - attach the pins as shown in the images. Be sure to attach the "right" servomotor to input 1 and the "left" servomotor to input 2.
5. Attach the NeoPixel Ring to the other Arduino. Connect PWR to 5V, GND to GND and Data Input to pin 6.
Step 3: Assemble the Robot Drum Sticks
Next up, lets set up the actual robot drummer itself!
1. Prep drum sticks: Likely a full drumstick will be too long and heavy to be usable. We wound up cutting our drumsticks in half. We recommend testing different lengths with your own setup; just remember, you can always cut more off but you can't re-attach what you've already cut! Well.... not without a bunch of extra effort, anyway.
2. Attach drum sticks to the servomotors: attach an arm to the servomotor; most hobby servos will come with a few choices. A long, narrow and straight arm will likely be your best bet. Use two-sided tape to adhere the drumstick to the servomotor and tie it down to the arm with some plastic ties.
3. Set up the finished Robot Drum Sticks: using two-sided tape, stick the finished servo-drum sticks to the appropriate 2x4s. Be careful that the drum stick on the left is the one attached to servo input 2 on the Adafruit Motor Shield and the drum stick on the right is attached to servo input 1.
NOTE: Should you be so inclined, you could definitely use screws to attach the servomotor to the 2x4s; we found that to be too finicky for our tastes - two-sided tape worked just fine!
Step 4: Almost Done
It's almost party time! But first...
1. Attach the Adafruit NeoPixel Ring: Using two-sided tape, stick the NeoPixel ring to the back side of the snare drum. Make sure the lights are facing inwards on the snare drum for maximum effectiveness.
2. Finish the Ultrasonic Sensor: Using two-sided tape, stick the ultrasonic sensor on the final 2x4 chunk. Ensure it's facing outwards & away from the snare drum!
Step 5: The Code
These are the final steps necessary before your party can get into full swing.
Arduino Code: You will need to install the Arduino integrated development environment (IDE) on your computer first of all. It can be downloaded from https://www.arduino.cc/en/Main/Software for free!
- The Arduino IDE is used to load code onto the Arduino boards. Once the code is loaded, it will continually be run by the boards while they are powered.
- Once it is set up and installed, you will need to add 3 libraries (extra pre-written code packages) to your IDE. This can be done by opening the IDE, selecting "Sketch" from the top menu bar, then going "Include Library" and finally choosing "Manage Libraries...". This will bring up a new window where you can select libraries to add! You're looking for one called "Ultrasonic", one called "Servo" (this one may be already installed when you download the IDE), and one called "Adafruit NeoPixel". You can use the bar that says "Filter your search..." in the top right corner to find these libraries quickly and easily. When you've found an appropriate library, click it and then click the button in the bottom right that says "Install".
- Once you have the IDE and the libraries installed, now it's time to download the code! Attached here are two ".ino" files, or "Sketches". Download the one called Drums.ino and then the one called Party_Lights.ino.
- Open the Sketch called "Drums.ino". Attach the USB connector cable that comes with the Arduino kits to both your laptop and the Arduino board that is connected to the servomotors/ultrasonic sensor. On the Arduino IDE, click "Tools" from the menu bar options, then hover over the option that starts with "Board: ". On the list of options that appears, select "Arduino/Genuino Uno". Click the button at the top of the screen that is shaped like a right-facing arrow that says "Upload". This sends the code from your computer to the Arduino board!
- Repeat the last paragraphs instructions, but this time do it for the Sketch called "Party_Lights.ino" and connect it to the Arduino board with the NeoPixel Ring attached to it.
Processing Code: Next you will need to install the Processing IDE. Like Arduino, it is a free program and can be found at https://processing.org/download/
- The Processing IDE is used to capture keyboard input and send that data to your Arduino boards, which will respond appropriately.
- Once it is installed, all you'll need to do is download the code here called "drumsProcessing.pde" and open it in a Sketch.
Step 6: Running the Project
Awww yes, it's officially party time!
NOTE: Before continuing, we recommend listening to the song "Party Hard" by Andrew WK, but this is an optional step.
Plug both Ardunio boards via USB into your computer: This will power them!
Run the Processing Sketch: When you click the Play button at the top, a new grey window will open up. Make sure this is in focus! Hit the "a" key - this should cause the left drumstick to swivel and the NeoPixel Ring to flash. Next, hit the "l" key - this should cause the right drumstick to swivel and the NeoPixel Ring to flash as well.
NOTE: If nothing is happening, you may have Caps Lock selected - this causes Processing to misinterpret your keystrokes. Also, if you don't have the grey window in focus, Processing won't be able to read your commands.
NOTE: You may need to re-adjust your servo motors! Take the arm off of the servo and adjust the angle accordingly; ideally, the drumsticks should be set up perpendicular to your board edge, and should only stick out a little bit when activated.
Test the Ultrasonic Sensor: When you hold your hand within 50 centimeters of the sensor, it should trigger a simple pattern played by the drumsticks. When you hold it up close to the sensor, it should trigger a "freakout" - the sticks will hit in rapid succession.
NOTE: If this is not working, you may have your Arduino boards hooked up to the wrong USB ports on your computer. Adjust which board is plugged into which port!
Place the Snare Drum: Once you're certain the whole project is working properly, place the snare drum in front of the drumsticks and get your party started! To make sure your party is next level, be sure to tie a helium balloon to the top of the snare drum; this will signal your partying intentions to others near and far. .