So, I've got a music degree, 5 years programming with Ruby and 7 with Pure Data. I've also got hold of an Arduino and a Raspberry Pi.

Anyway, I've seen a number of Arduino projects which involve firing events which cause a stick to hit a drum, but I really don't know where to start.

I have a wicker penguin that I want to have play the drums:

  • What components do I need to produce this kind of one-off percussive event?
  • Can I trigger these events from Ruby?
  • Welcome to Arduino SE! I edited your question a bit, removing the request for tutorials. Stack Exchange is a repository of information, not a repository of links. If you have any questions, please feel free to reply to this content. Thanks! (Also, penguins are awesome :-D) May 29 '15 at 15:18
  • I'm not sure about removing the last sentence, as it explains what the penguin image is for, but it appears I can't edit that part of it with a rep of 101.
    – AJFaraday
    May 29 '15 at 15:30
  • Fixed that, apologies. May 29 '15 at 15:32
  • I think the most challenging part of this project will be coming up with an electro-mechanical mechanism which moves the arms in a good drumming motion, without depending on an expensive, power hungry industrial servomotor and driver. A sensor-equipped brushless motor off a large RC car might work well, but finding or creating a suitable controller could be a challenge. May 29 '15 at 15:39
  • On a smaller scale you could try a solenoid and a spring... unless you happen to have one of the huge ones from a mainframe removable-platter hard disk mechanism (I once saw such driving a rocking chair!) Some combination of a motor, cam, arm with a return spring, and an encoder for position and speed feedback might also work. May 29 '15 at 15:44

The approach I would take for the arms is to use a servo motor as these are fairly cheap and are closed loop so you don't have to add any extra sensors to check where the current position is.

Types of Motors:

  • Stepper motors are a type of motor with a special arrangement of coils that allows you to turn a fraction of a degree by sending pulses to the motor. For example, you can buy a 200 step stepper motor that turns in increments of 1.8 degrees. These are somewhat expensive and require somewhat expensive drivers (usually $5-10 per driver). Often used in CNC machines and 3D printers. Continuous rotation.
  • General DC motors (two types: brushless and brushed, but I won't get into that in here) are a type of motor. Their drivers are often cheaper than one for a stepper motor, but you have little control over their rotation (instead of "take one step which is X degrees," you say , "turn at 25% power clockwise," where you don't know the actual speed). These are sometimes used with rotary encoders or potentiometers to control the speed and position of the spindle. Continuous rotation.
  • Servo motors are actually not their own type of motors; they are DC motors (not steppers) with a potentiometer built in along with the driver. You send pulses to it (you can use the Arduino servo library for this) to tell it the exact degree to go to. Can only go a limited range: usually either 90 or 180 degree, although you can get special ones that can turn much longer ranges than that.

Using a Servo Motor:

You can hook it up like this:

From this Arduino Tutorial

And then some very simple code to use the motor:

#include <Servo.h> 

Servo myservo;

void setup() {

void loop() {

Talking with Ruby:

Your best option is to use the serial port on your computer. Figure out how to access a COM/serial port in Ruby. You can then send messages from your computer to the Arduino, but you'll have to figure out a way to structure the messages.

  • This may work for limited purposes, but a typical RC servo has a relatively slow transit time which will limit achievable tempo. I'd also be concerned about damaging the gears unless there is a fair amount of flex in the mechanism - which may be needed also in order to let the stick or mallet spring back enough to avoid deadening the sound. May 29 '15 at 15:40
  • @ChrisStratton the stick height would have to be pretty small (although that may make it to quiet, although I doubt many people would have an objection to a drummer wicker penguin being quiet). Also, I don't think it's the OP's expectations to have it play thirty-second notes at 150 BPM, but you're right that a more powerful servo will be needed. In addition, the OP might want to have it "grip" the sticks towards the middle so it doesn't have as much pressure as the sticks act as levers. May 29 '15 at 15:45
  • I really don't think they would get much sound without a whipping action from driving a longer, flexible stick. I will grant they are faster than I remembered though: say .2 seconds each way, so with care to time the commands just right 120 BPM quarter notes might be achieved. May 29 '15 at 15:50
  • Thanks, this looks like a really handy primer for motor components. On the Ruby interaction part, does this mean I should create functions in the arduino syntax, upload them to the arduino, then trigger them from Ruby using the serial port?
    – AJFaraday
    May 29 '15 at 15:50
  • @ChrisStratton .2 each way would yield eighth notes at 150 clicks (60 seconds per minute / .4 seconds per hit = 150 hits a minute with 2 sticks = approx. 150 BPM eighths) May 29 '15 at 15:55
  • to move the arms: look for tutorials about arduino controlling a motor (either step od DC).
  • to control the arduino from a PC (or the PI) - that's what it means when you say Ruby - check how to remote control over serial port
  • 1
    If you want to have a look, I did something similar in python. Ii emulates a USB keyboard, but you can add more commands to support the control of the motors. github.com/01org-AutomatedFlasherTester/pem May 29 '15 at 14:35
  • I'm not sure if this is the answer yet, until I can spend a bit of time on it, but it looks like the serial port control is probably going to be the correct approach.
    – AJFaraday
    May 29 '15 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.