About a month ago I helped build a musical fruit fly experiment for a science fair held at The Edge. The idea was to combine art and science in a way that would appeal to a wide audience, so we turned a simple experiment into a musical instrument that people could “play”.

The Art and Technology:

Local kinetic artist Michael Candy designed up a bunch of keyboard style keys, speaker and monitor mounts that I hammered out on my RepRap 3D printer. With Daniel Flood and Mick Byrne we built some plinths to hold the experiment. I hacked together a simple circuit for measuring the resistance of the vegetables, as well as detecting switch presses - all plumed into an Arduino uno.

a sketch of the circuit used to measure fruit resistance

I wrote an Arduino sketch that would measure the resistance of each of the four inputs every 10 seconds. The measurements were then dumped onto the serial port so that it could be scooped up and saved to disk (I’ll get back to this in the science section). I was also listening for key presses, and took the current resistance reading of the corresponding piece of fruit and pushed that into the excellent Mozzi sound synthesis library. These readings were used to determine the output frequency or ‘note’ for the piece of fruit at that point in time. Mozzi dumped the sounds out on the PWM Digital 9 pin and through a cheap amp which drove the speaker mounted on the front.

As you can see from the above video, we got a great range out of our four pieces of fruit (although the lower tones are a bit hard to make out in the video). The really interesting thing was the way ‘chords’ sounded, or what happened when you held down multiple keys. It certainly didn’t sound like a piano - more like a loud distorted noise. Holding down different key combinations produced different distorted noises; not exactly what I was shooting for, but people seemed to enjoy it.

A photo of untitled sound project two installed at the edge, in queensland australia.

The Science:

Dr Caroline Hauxwell from the Queensland University of Technology supplied a couple of different fruit fly species and designed the experiment. Caroline was looking to see how fruit fly infestation would change the resistance (sometimes used as a way of measuring fruit quality) of different kinds of fruit. We had two groups, one with tomatoes and the other with bananas. Each group had a control fruit (not infested with fruit flies) and an infested fruit, i.e.

  1. Tomato with fruit fly.
  2. Tomato without fruit fly.
  3. Banana without fruit fly.
  4. Banana with fruit fly.

As mentioned above, I was using the Arduino to poll resistance every ten seconds. I then wrote a little Ruby script that ran on a laptop. This script took the contents of the serial port and dumped the measurements to a CSV file. From here I had a HTML file that charted the CSV file using the excellent D3.js. This page was loaded into Chrome and full-screened for the LCD display. I also installed a Chrome plugin to reload the web-page every five minutes. This would update the chart with the latest resistance results that had been saved to the CSV file.

In the end, we realised we needed to rerun the experiment if we wanted accurate results. The lights underneath each of the pieces of fruit, while they made it look good, introduced so much heat that it had an impact on the resistance readings. We had big swings when the lights came on during the day and at night when the lights got switched off. Perhaps it wasn’t not the most scientifically rigorous experiment, but it definitely looked and sounded cool! And hopefully it also taught people a little about how to craft an experiment.

A detail photo of a tomato in a large glass jug

You can find the source code for the data logger, sound generator and chart generator on GitHub. The collected data can also be found here.


You can join the conversation on Twitter or Instagram

Become a Patreon to get early and behind-the-scenes access along with email notifications for each new post.