`
`1a.,.in
`
`.0.
`
`65?‘
`
`
`
`
`
`412
`
`Chapter 21 = Playing Musical instruments
`
`introduction
`
`Chapter 6 describes the sound system of the RCX and the way you can program
`it to produce music. Here we are going to explore a more indirect way of per-
`where our robot actuall
`la 5 an instrument.
`V
`Y P V
`forming music, one
`atures described in this chapter lies
`The main difference between the two cre
`rn LEGO—made drum—set
`in their instruments.The first, a drummer, plays a custo
`ms on a real
`designed for the task, while the second, a pianist, perfor
`specifically
`u’ll see, reflects heavily on their architecture; the chess
`piano. This diversity, as yo
`ou that interfacing LEGO with real~world
`machine of Chapter 20 taught y
`e, is usually difficult and requires a great
`objects, no matter how common they ar
`deal of effort (and many partsl).
`
`Creating a Drummer
`The part you need to base your drummer design on, not surprisingly, is the drum
`set. From what we know, LEGO doesn’t make any part that acts as a drum, so
`and come up with an alternative.When we
`you need to be imaginative
`mind as an option, but then we felt a
`attempted this, small cans first came to
`more LEGO—like solution might be appropriate, so we started rummaging
`through our drawers searching for a part that might provide the right inspiration.
`That’s when we came Lipon the wheel hubs.They seemed perfectly suited for
`our goal, their shape closely resembling that of a real druni.The only missing part
`was the “skin,” the diaphragm that covers drums and that produces the sound
`when hit. A visit to the kitchen solved this problem, too: ordinary plastic wrap
`provided us with an answer. We stretched two tight layers of it on one side of the
`hub, secured it with a rubber band, trimmed the excess wrap, and our drum was
`ready to use.
`faced regarded the sticks and, more importantly, the
`The second problem we
`rig a drum is more a matter of speed than strength:
`percussion mechanism. Playi
`tly withdraw, helped in this
`the stick must hit the drum very quickly and promp
`s in order to emulate
`by the boLince.We tinkered with some different mechanism
`’s swinging moVem.ent—vvith little success. Have you ever
`a human drummer
`for a complex solution, only to find
`banged your head against the wall searching
`d
`an answer that’s not only incredibly simple? Better late than never, we discovere
`that an axle perpendicularly attached to the motor does the trick. Keeping thff
`motor powered for a Very short time and then switching it into float mode
`causes it to pass on enough speed to the “stick” that it bounces back with no
`resistance.
`
`
`
`
`
`
`
`Playing Musical instruments - Chapter 21
`
`413
`
`Building the Drummer
`
`With the basic design and material problems solved, the rest of the robot came
`together quite easily (Figure 21.1). It is, indeed, one of the simplest robots in the
`book, made only from MINDSTORMS parts with a third (optional) motor
`
`added in.
`
`Figure 21.1 The Drummer
`
`The drum set contains a bass drum, a torn-
`tom, and a cymbal, though the
`latter sounds rather
`dull, since it’s a piece of plastic rather than 21 true cymbal!
`(Figure 21.2).
`
`
`
`
`
`Chapter 21 ° Playing Musical Instruments
`
`
`
`
`Figure 21.2 Drummer Top View
`
`
`
`Both the sticks and the pedal feature 21 slack belt that helps them
`their neutral position (Figure 21.3).
`
`1”€U.1I'1’l
`
`t
`
`Figure 21.3 Drummer Left Side View
`
`
`
`
`
`Figure 21.4 Drummer Front View
`
`Two 16 long beams run Vertically
`motors and the RCX (Figure 21.5).
`
`across the back of the robot, supporting the
`
`
`
`
`
` 416
`
`Chapter 21 - Playing Musical instruments
`
`Figure 21.5 Drummer Rear View
`
`Programming the Drummer
`simplicity of the structure corresponds to the
`This is one of those cases where the
`simplicity of the software.As we explained earlier, all you have to do to use the
`sticks is to run the motor for a Very short time before switching it into float mod
`In our test version, we kept the motor on for just two hundredths of a second.
`Create three routines (or macros) that correspond to the left and right stick
`s the pedal. Each one will have a structure similar to the following NC
`example:
`
`as well a
`
`
`
`void right_stick()
`
`On (OU‘I‘_C) ;
`
`Wait(2);
`
`
`
`
`
`
`
`Piaying Musical instruments - Chapter 21
`
`the combined action of
`
`We recommend you also Write some subroutines for
`two motors (or all three), so that when you want multiple strokes made, they
`occur together, in synch.\X/hen you’re done with this, you are ready to code your
`first drum pattern, which is composed of a series of strokes and pauses.
`
`
`
`Variations
`
`You have probably noticed that this robot has no sensors. It doesn’t need them to
`play, but they could add interesting functionalities. Used as input devices, the
`touch sensors can be programmed to increase or decrease the tempo of the eXe—
`cution, or to trigger a change of pattern or a fill—in.
`The addition of a light sensor offers you the opportunity to conduct the per-
`formance With a flashlight. For example, the robot could read the time between
`two passages of the light beam on the sensor, and use that interval as a value for
`the duration of a beat.
`
`Creating a Pianist
`
`As announced in the introduction, the Pianist has been designed with the ambi-
`tious goal of playing on a real piano. It follows the scheme we implemented in
`the S16 robot that we published on our site.This time we made it even more dif-
`ficult, aiming at an acoustic piano rather than at an electronic keyboard, requiring
`a stronger and faster striking of the key to produce the note.
`
`Buiiding the Pianist
`
`This robot requires a lot of extra parts, mainly beams and plates used to make the
`structure solid enough to Withstand the forces involved in the pei'foi‘niance.'\X/h
`at
`seems a gentle touch to a human hand, is a strong effort for the small LEGO
`motors. Consider also that you cannot gear them down too much, because an
`acoustic piano needs a minimum speed on its keys for the hainmers to beat the
`strings.
`Figure 21.6 shows the Pianist in action.You see that its feet go under the
`keyboard, a simple but effective way to oppose the resistance of the keys and keep
`the fingers in their place.
`ltis amazing how well the distance between the keys matches three LEGO
`units (Figure 2l.7).This makes our pianist have its six fingers precisely positioned
`In the center of each key. As the robot has no mobility (keeping it from reaching
`the rest of the keyboard) , its only able to play six adjacent white keys.
`
`
`
`
`
`
`
`‘_,.,.._,,_..,_n.p.....,.._.u..,,,.‘
`
`
`
`418
`
`Chapter 21 - Play
`
`ing
`
`Mus
`
`ice! I
`
`['15
`
`tm me
`
`rriis
`
`1..2Er.UMJF
`
`fl
`
`_|.
`
`.5HEPE..h..u.
`
`.T.
`
`Figure 21.77 Top View of the P
`
`ganist at the Keyboard
`
`
`
`
`Piaying Musical instruments 5 Chapter 21
`....,,,.,..,_Hm,nnm‘.¢<"*-‘?rvnr=mn:IvtrnrM"«'“‘T’f*“5'Fi"'*5‘”“""7‘3
`
`As we said, though conceptuaily simple, this robot requires a lot of strength-
`ening.We braced the entire system that operates the fingers between two strong
`compound beams protruding off the sides of the robot (Figure 21.8).
`Figure 21.8 Pianist Front View
`
`
`
`
`
`
`
`7
`I
`
`The head of the robot, with its funky glasses, as you inay have guessed, is
`purely decorative.
`The robot uses three motors, each one coritroihng two flngers.\X/hen one
`61‘ goes down, its mate goes up. Figure 21.9 shows the mechanisiii of a pair of
`fingers with the components slightly taken apart so you can better understand
`how it works.
`
`fing
`
`
`
`
`
`
`
`° Playing Musical instruments
`
`Chapter 2’!
`
`Figure 21.9 Pianist Finger Mechanism
`
`
`
`Our pianist contains three finger groups 1i1:e that one, placed side by side.To
`Show them more clearly, We removed the RCX and the strong traversal beam
`that keeps the fingers together {Figure 21.10).There’s no need for rubber bands
`1
`or other systems to center the f ngers since the keys themselves provide the push
`that lifts them back up.
`The sides of the robot are easily adjtistable in height, so you can adapt thfi‘
`structure to different keyboards (Figure 21.11).
`At the bottom of the structure is a row of parallel 1o11gitudir1a1 beams sup-
`porting the motors (Figure 21,12).
`
`
`
`
`
`
`
`E.
`
`12ErU.m..
`
`an...
`
`idnEP0.
`
`_m+L
`
`wEVD.
`
`F.BdnaXCRh.+hM
`
`ams Removed
`
`)
`
`Playing iviusica! Instruments ° Chapter 21
`
`Figure 21.11 P
`
`ianist Side View
`
`
`
`422
`
`Chapter 21 ~ Playing Musicai instruments
`
`Figure 21.12 Pianist Rear—Eottom View
`
`limited
`
`l ay
`
`
`
`Programming the Pianist
`The technique required to program this robot is indeed. very similar to the
`Drummer. In this case, keep the motors on a bit longer: Our Version Works with
`21 timing of eight hundredths of 21 second.
`‘Write a short routine for the activation of each finger, naniing them after
`the corresponding notes. In Figure 21.7, you see the Pianist positioned on six
`notes that go from B to G, while our code, in fact, contains six routines B0, C0,
`D0... G0.
`We wrote the code to play chords, too. The Pianist actually supports 21
`polyphony and can perform two or three note Chords, provided they dont
`include two notes controllecl by the same motor. Staying zigaiii with our exzmiplfi.
`C+E is 3 Valid coinhination, While D+E is not.
`ng '3
`Similar to What you did for the Drummer, construct your melody usi
`.
`sequence of calls to the note routines interleaved with pauses. Build your dc?
`Values starting from the shortest note your melody cont;1lns.Let’s say you’re gomg
`
`
`
`
`
`move, so your delay will be 25 ~ 8 =
`quarter——one heat-—-should last 50 hundredths, resulting in a delay of 42, While a
`half note (100 huridredths) should have a corresponding delay of92.
`
`riiyaytsia:ii%ih2‘ng,érrggsyzaggasiiifaigiyt
`_;rat:on,~ ,QQ.l{ at ~-sore rs“ m
`A.‘
`-
`_
`1:0
`t:'r_u:it’eseso the ptigptif
`
`L
`
`'
`
`fne.
`
`i
`
`9.“:
`
`V
`
`In
`
`15
`The Pianist, like the Drummer, doesn’t feature any
`input sensor. lt is actually fit for
`the same kind of applications used for
`touch and light sensors: tempo changes and
`performance Variations.
`‘(X/ith a sound sensor capable of decoding pitch, like the one
`described in Chapter 9, you can make your Piailist “learn” and reproduce what you
`_ play on a sepa
`rate section of the same keyboard or on
`another instrument.
`In case you have a second RC
`X, you can make it control the Pi
`anist Via IR
`essages. For exainple, you c
`an build a robot that reads
`21 special format score,
`decodes the notes
`and converts them into instructions
`for the Pianist.
`If you want your own Pianist to play
`an organ rather than a piano (
`Speaking, 21 keyboard that emulates
`or, generally
`an instrument that requires long notes), you
`must figure out a system to keep the keys down Without dainagirig the n1otors.A
`33111316 solution requires that you replace the 24t gears on the motors with clutch
`ge'=11'3, 80 you can keep the motor running without danger of dainaging then1.You’ll
`P1”0l3al3ly discover that running them continuously is unnecessary. since you can
`
`
`
`
`
`Chapter 21 - Playing Musical Instruments
`
`brake the motors when the key is down, possibly turning them on once in a While
`if the note has to hold for a very long time.
`
`Qther Suggestions
`The instruments we assigned to the robots of this chapter are n.ot the result of a
`random choice:They are the easiest to build!
`le to vibraphone, are a feasible
`Percussive instruments in general, from triang
`e minor adaptations to our
`option. Keyboard instruments are, too, if you niak
`design Whenever necessary.
`ems difficult
`Strings instruments are a tough challenge: Playing a real guitar se
`enough, never mind playing a violin.You can probably make a very simplified
`LEGO version of a “guitar” where your robot controls the tension or length of a
`single string with a motor, while plucking it at the opposite end with a second
`motor.
`nsidering the
`Wind instruments appear out of range at the present time co
`(even a recorder is too demanding for a LEGO com-
`quantity of air they require
`pressor). But we’d love to be proven wrong on this topic!
`
`
`
`Summary
`
`n the android evolutionary scale:
`The robots of this chapter are a bit low o
`he environment.The Drummer is
`Having no sensors they cannot interact with t
`they show some techniques useful
`so simple it doesn’t even have gears! However,
`d the Pianist itself describes a
`for situations Where you need a “fast touch,” an
`otor can control two mechanisms
`practical application of the principle Wher
`a in
`each one needing only one clirection.You have also discovered that sometimes
`you can resort to non—LEGO materials to complete your projects:The common
`plastic wrap is What made our robotic Drummer possible.
`LEGO robots capable of reproducing your favorit
`Well, if you were expecting
`hoven piano sonata, We probably disap—
`pop song, or to perform some classic Beet
`pointed you.]ust the same, we hope our players surprised and amused you, and
`that they have provided some inspiration for your own musical creatures.