Playing Bach on an Arduino UNO

In a previous post, I demonstrated how an Arduino UNO can be programmed to play a simple melody (“Mary Had a Little Lamb”) and work as a stand-alone device without the need for a USB cable connection to the computer.

Here, I’d like to show that “dueling Arduinos” can do even more.  In this case, I have two Arduino UNOs in combination, performing the first twelve bars of J.S. Bach’s Two-Part Invention No. 8 in F Major. I assigned the soprano part to one UNO and the alto part to the other.  Success lies in having the same type of speaker for both units so that volume and tone timbres are not mismatched.  In this case, I used two 8-ohm, 1-1/8″ (28 mm) diameter mini speakers  (Radio Shack part #273-0092, $3.99) and two, 9-volt battery power sources for each.

You may wonder why two Arduinos are used here. After all, a single Arduino UNO is capable of hosting two speakers connected to different input pins and grounds and utilizing a single power source.  The problem, however, is not with the hardware.  Rather, it lies in the complexity of the programming code needed in order for a single UNO device to play polyphony or harmony on two speakers.  After doing research on the code required, I decided that it would be easier and faster to simply assign the different parts to separate units, much the way that orchestral scores are arranged. To use a musical analogy, it’s a bit easier for someone playing a clarinet or someone playing a flute to each play a part and then play them together in combination than it is for a single pianist to play both parts at the same time.  It can be done, of course, but having studying both monophonic and polyphonic instruments, it is indeed easier to play a single line on a musical instrument than multiple parts simultaneously (while working as an organist, I often felt a bit like an octopus with two hands and two feet all coordinating at the same time–and wishing I had four more limbs to make the job easier).

Given that UNOs are relatively cheap devices (under $30.00), it made sense then to simply assign individual parts to individual units.  Also, it was easy to write two separate programs for the two voices.  Thanks to Bach’s particular polyphony with its beautiful symmetry between parts, coding the second voice doesn’t require very much work–just a bit of tweaking from the original program.  With a synchronized start of the two UNOS, they perform together admirably, much like two musicians. And, after having called myself an “electronic musician” for many years, the title took on a whole new meaning after this project.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s