Main Content

Hello! That’s the story of how I made my automatic barrel piano on the Arduino.
This project was done exclusively for fun and does not imply the real use =)

The idea of automatic musical instruments isn’t new at all. People always tried to automate various musical instruments, including the piano. There were different automatic pianos from the mid-18th century until the invention of the gramophone, for example, a barrel piano (pic. 1), a player piano, also known as pianola (pic. 2) or a barrel organ (also known as a street organ or hand-organ). These devices were automated using a pneumatic or mechanical system. Pianola has a driven shaft, with protrusions located in a specific sequence, according to the notes of the musical piece. The protrusions of the shaft sequentially drive the mallets corresponding to the keys of the pianola and thus extract musical sounds. Inside of a barrel organ, there are sounding tubes, bellows, and a wooden or metal roller with spiked fists placed in several rows (pic. 3). Turning the knob, the organ-grinder could play 6-8 melodies recorded on the roller. In the late XIX - early XX centuries, more advanced tools appeared with keys controlled using perforated paper tapes.

The first task is to figure out whether the key is pressed or not.

Old musical instruments use rather complex mechanisms with shafts projections and valves. I can use Arduino and electronic sensors to get the presence signals of a particular sound; for example, optocoupler sensors also called line sensors. Optocouplers are used in the Arduino world for line racing. These sensors allow you to determine the white or black color of the surface below it.

Here is the idea (pic. 1). Let the line sensor represent one piano key. Place several white and black areas on a sheet of paper. Then, move this sheet relative to the stationary line sensor. If there is a white area of the sheet below the sensor, then the key is released. If a sensor detects a black area, then the key is pressed. At the moment when the key goes from the released state to the pressed state, a note begins to sound.

With multiple optocouplers at the same time, you can create a kind of a piano keyboard where each optocoupler corresponds to its note. By positioning black and white areas on the sheet in a certain way and moving the sheet at the desired speed, you can get the note sequence of a musical piece.

I made a keyboard consisting of 40 keys. For this, I used five Octoliner modules. The Octoliner module is a small array of optocoupler sensors. Each module has eight TCRT5000 optocoupler sensors, so one module can be used for 8 different piano keys. This module runs through the I2C bus, and it is easy to link it with Arduino.

I decided to place five modules next to each other to create a single vast linear array of 40 (5x8) optocoupler sensors. You can make a keyboard from fewer keys or make a full-size piano keyboard with 88 keys. I chose 40 because this is about half of all the keys on a real instrument.”

Link to article