Arduino Servo Drum Machine
This is a simple two micro-servo and Arduino Uno controlled drum machine or robot. The servos are mounted on an L-shaped bracket of wood that is held to the snare drum with 4 strong magnets. The servo arms are bolted to two chopsticks which serve as the drum-sticks. It is quite loud but not too loud. Much louder hits could be obtained by using standard size servos and real drum-sticks which are quite a bit heavier. But that would also require a separate power supply for the servos. By using micro-servos the Arduino supplies enough current to power them directly without a separate power supply.
The video shows my attempt at programming a simple version of the Wipeout drum solo. Of course it is not at the real 160 beats per minute but that could easily be obtained by adding another servo which would be pretty cool. I haven't calculated what the top bpm that can be obtained by using a servo and it does require some delay in getting the drumstick from its parked position to the drum-head.
The rhythms you can create are only limited by your imagination and the drum machine is a more interesting companion to play with than a digital drum machine, if you are a musician.
The only downside is the servo noise which isn't really that noticeable though the camera audio seems to pick it up quite notably.
Build the Servo Bracket
This bracket is made from some strips of hobby plywood I had on hand. I created an L-shape by bolted two pieces together with a metal L-bracket. Then a small block of wood was glued to the top strip to hold the two servos.
I had two handy servo brackets which I screwed to the block of wood.
I used 4 neodymium magnets to hold the bracket to the snare drum.
Wire the Servos to the Arduino Uno
The servos vcc (middle wire) goes to the Arduino 5 v pins.
The Ground wires to Arduino ground.
The signal wires go to pins 6 and 7.
A servo shield would make it even easier if you have one.
Arduino Code...
Below is the simple sketch to play Wipeout. You just have to adjust the servo positions for your particular setup.
Have fun!
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "servo.h"
// servo drummer Jim Demello June 2018
Servo myservo1,myservo2;
int servoPin6 = 6; //servo
int servoPin7 = 7;
void myServo(int servoPosition, int servoNumber) {
if (servoNumber == 1) {
myservo1.write(servoPosition);
}
if (servoNumber == 2) {
myservo2.write(servoPosition);
}
}
void doOneEighthNote(int servoNumber,int beat) {
int delayVal = 60;
if (servoNumber == 1) {
if (beat) {beat = 10; // if beat = 1 then add a little more servo down for stronger thump
}
myServo(150 + beat,servoNumber); //down
delay(delayVal);
myServo(100,servoNumber);//up
delay(delayVal);
}
if (servoNumber == 2) {
if (beat) beat = -10;
myServo(60 + beat,servoNumber); //down
delay(delayVal);
myServo(80,servoNumber);//up
delay(delayVal);
}
}
void setup()
{
// Serial.begin(9600);
myservo1.attach(servoPin6, 1000, 2000); // attaches the servo on pin 9 to the servo object
myservo1.write(100);
myservo2.attach(servoPin7, 1000, 2000); // attaches the servo on pin 9 to the servo object
myservo2.write(90);
}
void loop() {
wipeout(); // wipeout drum routine
//doOneEighthNote(2,0);
delay(40);
}
void wipeout() {
doOneEighthNote(2,1); doOneEighthNote(1,0); doOneEighthNote(2,0); doOneEighthNote(1,0); // first parm is servo number and second parm is beat (1=beat, 0=no beat)
doOneEighthNote(2,1); doOneEighthNote(1,0); doOneEighthNote(2,0); doOneEighthNote(1,0);
doOneEighthNote(2,1); doOneEighthNote(1,0); doOneEighthNote(2,0); doOneEighthNote(1,0);
doOneEighthNote(2,1); doOneEighthNote(1,0); doOneEighthNote(2,0); doOneEighthNote(1,0);
doOneEighthNote(2,1); doOneEighthNote(1,0); doOneEighthNote(2,0); doOneEighthNote(1,0);
doOneEighthNote(2,0); doOneEighthNote(1,0); doOneEighthNote(2,1); doOneEighthNote(1,0);
doOneEighthNote(2,0); doOneEighthNote(1,0); doOneEighthNote(2,0); doOneEighthNote(1,0);
doOneEighthNote(2,1); doOneEighthNote(1,0); doOneEighthNote(2,0); doOneEighthNote(1,0);
doOneEighthNote(2,1); doOneEighthNote(1,0); doOneEighthNote(2,0); doOneEighthNote(1,0);
doOneEighthNote(2,1); doOneEighthNote(1,0); doOneEighthNote(2,0); doOneEighthNote(1,0);
doOneEighthNote(2,1); doOneEighthNote(1,0); doOneEighthNote(2,0); doOneEighthNote(1,0);
doOneEighthNote(2,1); doOneEighthNote(1,0); doOneEighthNote(2,0); doOneEighthNote(1,0);
doOneEighthNote(2,1); doOneEighthNote(1,0); doOneEighthNote(2,0); doOneEighthNote(1,0);
doOneEighthNote(2,0); doOneEighthNote(1,0); doOneEighthNote(2,1); doOneEighthNote(1,0);
doOneEighthNote(2,0); doOneEighthNote(1,0); doOneEighthNote(2,1); doOneEighthNote(1,0);
doOneEighthNote(2,0); doOneEighthNote(1,0); doOneEighthNote(2,0); doOneEighthNote(1,0);
}