HackSpace – September 2019

(Jacob Rumans) #1

waiting until it is in position, moving the beater
downwards, waiting a few fractions of a second,
moving the beater back up, then finally pausing until
the next note, according to the desired tempo.


void playNote(int thisNote) {
if(thisNote >= 0 && thisNote <= 7) {
// note is valid, play note
bigServo.write(notePositions[thisNote]);
delayWhileUpdating(preHitDelay);
littleServo.write(beaterHitAngle);
delayWhileUpdating(postHitDelay);
littleServo.write(beaterRestAngle);
} else {
// delay instead of playing note
delayWhileUpdating(preHitDelay +
postHitDelay);
}
delayWhileUpdating(tempoDelay);
}

Upload this sketch to the Arduino, making sure the
external power supply is connected first, and press
the button. If all is well, the LED should come on and
the two servos should start twitching independently.
If this doesn’t happen, double-check your wiring.


ARMED AND DANGEROUS
You can now work out where to position your
glockenspiel and your large servo. Cut a piece of
wood to the desired length for your arm, and attach
an appropriate servo horn. Horns are the (usually
plastic) pieces that come with a servo and fit snugly
onto the servo’s shaft. Find an appropriately shaped
horn and screw it to the underside of your wooden
arm at one end. Mount the wooden arm on the
servo so that it is parallel with the long side of the
baseboard, aligning with the middle of the
glockenspiel. Make sure the servo is at its 90°
position when you do this (the sketch defaults to the
big servo being at 90° when it starts up).
The arm would work like this, but it’s best to secure
it down to the servo if possible. Some servos have an
M3 thread inside the shaft, allowing you to screw the
arm directly to the shaft. Alternatively, you might be

Top
;he Ieater was printed
Åat on one side unSiRe
a reNuSar NSoJRenspieS
Ieater to TaRe it
easier to print
Above
0M `ou find a desiNn
Åaw aMter printinN a
part it’s oMten possiISe
to IodNe it untiS `ou
Net around to printinN
a Ietter one
Left
0t’s possiISe to
IodNe an e_istinN
NSoJRenspieS Ieater
to worR with this
IuiSd iM neJessar` Iut
3+printinN a JustoT
one worRs Ietter

Getting the length of the arm right is important – too short,
and its arc of movement will be very small, meaning you
won’t be able to reach many notes on the glockenspiel
(which are laid out in a straight line). If you make it too
long, however, it may require too much force for the servo
to move the arm, even with the external power supply. For
our build, we found that 28 cm from the large servo’s shaft
to the tip of the beater was about right, with the actual
wooden part of the arm measuring 23 cm. This gave us a
wide enough arc to reach a whole octave of notes, without
appearing to stress the motor unduly.

Long arm of the law


LENS
Free download pdf