Backyard Brains Logo

Neuroscience for Everyone!

+1 (855) GET-SPIKES (855-438-7745)

items ()

Getting Started with the Muscle SpikerShield Pro

Hey everyone! I’m Pablo, a junior from Nido de Aguilas High School in Santiago, Chile. In my free time, I like to doodle and run.

My project is a multi-channel version of the experiment that my colleague and friend Cristian developed: it consists of using the SpikerShield Pro’s ability to get data from multiple channels to create a musical instrument. In this instrument, flexing a muscle is analogous to playing a key in a keyboard. Obviously, the amount of channels limits this keyboard to six notes, but according to my limited musical knowledge, this is enough to create a coherent melody. In fact, the Arduino program currently has four settings which can be accessed using the red button: Mary Had a Little Lamb, Frere Jacques, major pentatonic scale and the minor blues scale. All the notes are in arrays with six elements, each corresponding to a channel. To add more possibilities, holding the white button in the board makes all the notes in the current setting one octave higher. You can download my code here.

The “loop” part of the code works by reading the red button, white button, and all six channels. First, it decides which set of notes to use for that iteration of the loop, which is controlled by the red button, then it checks if the white button has been clicked, which affects the pitch of the final note it plays. The last step is to decide which tone to actually play, which the code does by selecting the largest reading of all the muscles. Now, you might be thinking that playing music with two vastly different muscles, say your forehead and your forearm, will never work because a signal from the forearm will always be bigger than the signal of even the strongest forehead flex. However, the SpikerShield Pro can control the gain from each individual channel (the little white knobs) which can make a channel more or less sensitive to a signal, so every muscle has a fair chance of being played.

One challenge I faced when I developed this project is the lack of documentation of this particular product for novice programmers. Most of the times I’ve played around with an Arduino, I’ve relied extensively on the built-in tutorials and online resources, but this time I only had the board’s schematic, which at first glance bears a closer resemblance to black spaghetti than a discernible circuit and the default program which sends the signals from the board to Spike Recorder. Running the aforementioned program was not a challenge, but reading the code, not being fully aware of what it was, proved to be confusing. I only started making progress once Tim Marzullo showed me an outdated sketch meant for this shield. However, with this project in the open, I doubt this is a problem other users will face; the heart of the code — presenting the sensor’s readings as an array and mapping those raw values to a usable scale — can be used for most projects.

The second biggest challenge was and still is, my absolute ignorance about music theory. I never learned to play an instrument, and the most complicated song I managed to play is “Hot Crossed Buns”, though that is probably a skill I’ve lost. I’ve always enjoyed music, but much like hot dogs, I preferred to enjoy the finished product rather than learning how it is made. After adding the melody of Mary Had a Little Lamb and Frere Jacques, I did not know what other songs to add. After a fair amount of research, I came upon pentatonic scales, which are comprised of five notes.

Though the musical aspect is worth examining, what attracted me more is its role in many musical traditions, ranging from the ancient Greeks to the Andes. During the 19th century, composers like Debussy used the simplicity of the scale to create a folksy in their composition, resulting in music like La fille aux cheveux de lin. Later on, rock, blues, and jazz artists adopted the scale as a tool for their respective styles of improvisation. I think this is the area where my particular instrument shows the most potential because it is only capable of playing one note at a time, and also because flexing muscles to create sound is very intuitive. However, this is a hypothesis I will let the reader confirm.

Make Music with your Muscles

Hi everyone! I’m Cristian, a junior at Nido de Aguilas High School in Chile. Aside from math and engineering, which are my main interests, I enjoy playing drums and reading nonfiction.

During my internship here at Backyard Brains, I’ve been working on building a musical instrument! It is a modification of our Muscle SpikerShield that measures the electrical signals going through your muscles and transforms them into a note or melody according to how much you flex! I feel proud to join a long tradition of musical instrument makers stretching back 35,000 years.

My musical box has four settings that produce four different outputs. You can change between these settings by pressing the red button on the Muscle SpikerShield. The first setting outputs a frequency that is proportional to how much you flex your arm, so if you really tighten your arm, it’ll output a high frequency, and if you untighten it, it’ll output a low frequency.

I am a very efficient coder. Look at my fundamental code. Rejoice in its beauty.
tone(8, finalReading/1.5, 100);

The second setting outputs notes on a chromatic scale, so you can play different melodies by changing how much you flex your arm.

The third setting plays “Mary had a Little Lamb” on repeat and, just like a real musical box, lets you alter the speed at which the melody plays. If nursery rhymes aren’t really your thing, you can always alter the code and change the melody. This is for all our circuit bending friends out there.

Lastly, the fourth setting lets you play the four notes that make up “Mary had a Little Lamb”, so you can try and create the melody yourself by flexing at different strengths, (which is very hard to do).

Below are two pictures of the setup you will need. Make sure to place jumpers in ground and digital pin 8 and connect them to an audio mini plug, as shown below. The miniplug can be from speakers or headphones. You can use alligator clips.

Additionally, make sure to place 3 electrodes in your muscle of preference ( I used my arm), and connect them to the Muscle SpikerShield with the orange electrode cables.

You can find the code for the musical box here. It includes comments that explain how everything works.