Introduction: Photonics Piano #phablabs

About: PHABLABS 4.0 is based on combining the World of Photonics (Science of light and light technologies) with the growing creative ecosystem of existing Fab Labs. The “Photonics Workshops” introduce a variety of fu…

Building a “piano”-like device where sound is at first replaced by colored light which is guided and diffused by optical fibers. Conversion of light into sound can be further implemented exploiting commonly available technology.

DISCLAIMER: By using this information you agree to be legally bound by these terms, which shall take effect immediately on your first use of the information. PHABLABS 4.0 consortium and its member organizations give no warranty that the provided information is accurate, up-to-date or complete. You are responsible for independently verifying the information. VUB cannot be held liable for any loss or damage that may arise directly or indirectly from the use of or reliance on the information and/or products provided. PHABLABS 4.0 consortium and its member organizations disclaim all responsibility to the maximum extent possible under applicable laws: All express or implied warranties in relation to the information and your use of it are excluded. All liability, including for negligence, to you arising directly or indirectly in connection with the information or from your use of it is excluded. This instruction is published under the Creative Commons licence CC-BY-NC.

Step 1: An Introduction: Refraction, Reflection, LEDs

Here we briefly introduce the technology of light that will be involved in the construction of the photonics piano.

The refractive index

The refractive index of a transparent medium (n) is the ratio between the speed of light in vacuum (c) and in the medium (v). This number indicates how much the light is slower in that medium with respect to the vacuum. For example, the refractive index in water is n(water) = c/v(water) ≈ 1.33, in glass n(glass) = c/v(glass) ≈ 1.52, in plexiglass n(plexy) = c/v(plexy) ≈ 1.49.

Reflection and refraction

When light hits the boundary between two materials with different refractive indices two things happen:

(a) Reflection: part of the light is reflected back with a reflection angle identical to the angle of incidence. Typically, all propagation directions are measured from the direction normal to the surface. In this case, referring to photo 1: alpha = beta

(b) Refraction: the rest of the light crosses the boundary and is transmitted in the second medium. The transmitted beam changes its propagation direction, and this change is what we call refraction. The new propagation direction, the refraction angle gamma is related to the incident angle alpha by the "Snell’s law": n(1).sin(alpha)=n(2).sin(gamma)

The beams and the angles alpha,beta and gamma are shown in photo 1, for the case in which n(2) > n(1).

Note that if we reverse the beam propagation, incident and refracted beams follow the same path, but in the opposite direction. In addition angles and obey the same Snell’s law. In photo 2, the beam propagates from lower to higher refractive index, and the transmitted beam is refracted towards the normal line; in photo 3, the beam propagates from higher to lower refractive index, and the transmitted beam increases its angle from the normal line.

Refraction is also responsible for the fact that when we observe an object in water, the object seems in a different position: this is because the light from the object gets deflected by refraction, while our brain tends to locate the objects by prolonging the rays propagating towards our eyes. This is sketched photo 2 &3, where refraction creates the illusion that the fish is along the dashed direction. This effect explains why a pencil immersed in water appears to be "broken"

Total internal reflection

As we have discussed, when light hits the boundary between two materials with different refractive indices, it is split into two rays, the reflected and the refracted one respectively. The total amount of light is preserved, but which ray is brighter, the reflected or the refracted one?

The splitting ratio between reflected and refracted depends on alpha and on the refractive indices, n(1) and n(2). Let’s estimate this splitting ratio when light travels into a medium with smaller index of refraction. In this case, according to Snell’s law, the refracted angle is greater than the incident angle, which means that the ray is bent away from the normal and towards the surface.

Concerning the energy, the closer is the refracted ray from the surface, the smaller is its power. This is schematically sketched in photo 4.

What happens when the refracted angle approaches 90°? And when it is larger than 90°? In this case, the refracted light is negligible, and all the energy of the incident light goes into the reflected ray. This process is called “total internal reflection”, and the surface separating the two media acts as a perfect mirror. From this observation, we can also easily calculate the critical incidence angle θc at which the refracted beam direction approaches 90°. The critical angle can be calculated from Snell's law by setting the refraction angle equal to 90°:

n(1).sin(90°) = n(2).sin(θc) → sin(θc) = n(1)/n(2)

Total internal reflection is the basic process governing light propagation in fiber optics. Their working principle is illustrated in photo 5.

Any time the beam hits the border of the inner medium (with n(2)>n(1)), if the incidence angle is larger than θc then it gets reflected. In principle light can propagate without energy losses along a fiber which could be several kilometers long. Photo 6

The following videos and figures show some examples of multiple reflections of a laser beam in water and in a Plexiglas slab.

The experiment with water can be easily done with the help of a laser (we recommend a green laser, since it can be better seen) and a fish tank with some water (few-centimeters-deep is more than enough). Put a spoon of salt into the water: this will enhance the visibility of the beam propagating in the liquid. If you shine the beam from outside the tank towards the water surface, you should see the reflected beam and some light should emerge from the surface (remember: never stare directly into the laser beam, therefore to check whether lights emerges from the surface, use a piece of paper and evaluated whether some transmitted light is projected on it). By changing the incidence angle, you will see that the transmitted beam vanishes, and all light goes into the reflected beam. Thanks to the internal reflection, you have just built a mirror…. without a mirror. If the water is not too deep, you should also see that the beam reflected from the surface, gets subsequently reflected also by the bottom surface of the tank, and directed back toward the surface. You have just built a liquid prototype of an optical fiber. Photo 7&8

LED and resistors


A diode is an electronic device which conducts current on only one direction, when its positive terminal (“Anode”) is connected to the “+” of a voltage supplier or a battery, and its negative terminal (“Cathode”) to the “-”.

When we connect its terminals the other way round, the diode behaves as an insulator and it does not conduct any current. It conducts electricity like the valve of a tire conducts air: air can be pumped from outside into the tire, but it cannot flow outside. Photo 9

There are many diodes for all kinds of purposes in electronics; some of them emit light. They are called “Light-Emitting Diodes”, or short “LEDs”. In this workshop, you are going to encounter LEDs shining in various colors. They will only light up if you connect them the right way (Anode to “+”, Cathode to “-“), they stay dark (and sometimes they burn) when connected the other way around.

How to recognize the Anode? It is usually the longer terminal wire.


A resistor is an electric device which conducts electricity when a voltage is applied to its end connections. The applied voltage V and the transmitted current I are related by “Ohm’s law”: V=RI
where R is called the “electrical resistance” and its units of measurement is Ohm (Ω). The units of the voltage V is the Volt (V), the unit of the current I is the Ampére (A). In contrast with the LED, a resistor conducts current in both directions, which means that it can be connected either way. Photo 10

In the workshop, the resistor will be used to limit the current that goes through the LED. Without it, the LED will likely get damaged. Each LED requires its own resistor before you connect it to a power supply.

Protecting the LEDs

To limit the current flowing through the LED, each LED is connected to a resistor, according to the scheme in photo 11.

Each LED works with a specific voltage V(L) and a preferred current; by choosing the proper resistor for any LED, it is possible to feed the LED with the desired voltage and current. In the workshop we will use a set of 7 LEDs (12 LEDs in the extended version). If they are all different (for example because they are of different colors) the value of each resistor must be chosen according to the properties of the corresponding LED.

Let’s now evaluate how to calculate the resistor for a typical LED.

In the workshop, the piano will be powered by a USB charger (or the USB port of a computer). The voltage of such power supply is 5V. Hence we calculate the resistance for the case

V(0) = 5V

Let’s consider a LED with the following characteristics (we took these data from the official technical sheet of the LED):

V(L) = 3V

I = 20 mA = 0.02A (suggested current)

According to the figure with the circuit:

V(0) = V(L) + V(R) → V(R) = V(0) – V(L) = 5V-3V = 2V

The current I flows through both the LED and the resistor. Therefore, from Ohm’s law we get the resistance of the resistor: R=V(R)/I = 5V/20mA = 250 Ohm

A resistor has a set of colored rings on it which denote its electrical resistance. See photo 12 for the encryption key.

Not all resistance values are available commercially. We suggest to choose, among the available ones, the resistor with the closest lower value of its resistance. In our case this is 220Ω. This corresponds to a current of 22mA, just a little higher than the suggested one, but still enough not to burn the LED.

Step 2: Part List

Photonics parts:

*Optical fibres with side glow effect, 3mm diameter (7 or 12 pieces, 40-50cm each)
*LEDs: 7 or 12 different colours

Other parts:
*Plastic/acrylic tube (internal diameter: 3.5mm; external diameter: 6mm; length: 1 m): 7 or 12 pieces
*12 resistors 230 Ohm
*12 resistors 390 Ohm
*Vinylic glue
*USB cable
*12 rubber bands, with diameter 2 to 5cm
*MDF sheet, cut according to the file PhotonicPiano.svg attached.

*solder iron

The photonics parts can be bought online:

Step 3: Assembling the Piano

We will now start mounting the piano by gluing the parts of the framework and the fibers. This requires various different activities:

1. Cutting the tubes

We will cut acrylic tubes, which will be used as keys for the piano, and will wrap the soft fibers.

2. Preparing the fibers

The fibers will be cut and glued on one piece of the frame.

3. Mounting the framework I - The keys holders

We will glue those wooden/MDF pieces of the framework that will hold the piano keys

4. Mounting the framework II - The sides

We will glue the lateral parts of the framework

5. Mounting the framework III - The tops

We will glue the top parts of the framework

Note: Activities 1, 2 and 3 are independent and could be switched: Since the glue needs some time to dry, we suggest to start from activity 3. and to do activities 1. and 2. while the glue is drying.

Step 4: Cutting the Tubes

We will cut acrylic tubes, which will be used as keys for the piano.


Cut the plastic/acrylic tube into 7 pieces. Length: 6 cm. (Photo 1)
Remove the leftovers and sand the two edges of each tube. (Photo 2&3)


Cut the plastic/acrylic tube into 12 pieces, instead of 7.

Step 5: Preparing the Fibers

The fibers will be cut and glued on one piece of the frame.


Cut the fibers with a pair of scissors. Each fiber should be from 40 to 50-cm long. Photo 1


The extended version of the photonic piano also includes the 5 half tones. In this case the total amount of fibers and keys is 12. This is the reason why parts A, B, C, D, E, F have 12 holes.

Step 6: Mounting the Framework I - the Keys Holders

The MDF sheet, cut according to file PhotonicPiano.svg, provides the pieces to assemble the framework of the photonic piano. In this step, we will assemble the holders of the piano keys.


Identify all the parts after laser cutting. (Photo 1) Label them with a pencil, it could be very helpful. Do not throw
away the small leftovers, they will be necessary in the next steps.

The holes must be aligned, you should be able to clearly see through them. (Photo 2&3)

Take piece A and its leftovers. The leftovers will be used as spacers in the following steps. (Photo 4&5)

Glue one spacer at each side of piece B (which has been previously glued to C, even if this picture does
not show that). (Photo 6-9)

Glue piece A on the spacers. The sequence should now be: A + spacers + B + C

Pieces A, B, C should be aligned; the holes and loops are also aligned. (Photo 10&11)


If the pieces are too soft and piece A bends when pressed, you can glue a spacer also in the middle. (Photo 12)

Glue the fibers in the holes of piece F. (Photo 13)

In which holes should I place the fibers? (Photo 14) In this figure you can see in which holes you should place the fibers (red lines) to mimic a piano keyboard. The BASIC procedure builds a piano with only the 7 natural notes.

Step 7: Mounting the Framework II - the Sides

We will now mount the sides of the framework.


Glue assembly A+B+C to one of the sides. Photo 1&2

Use the other side or a spacer to hold the assembly A+B+C in place while the glue dries. Photo 3

Glue piece D to the same Side. Note that the piece is larger, and it does not require any spacer to be held in place. Photo 4&5

Glue piece E to the same side. Note that piece E could be glued with the row of holes either in the upper or in the lower position: we suggest to glue piece E so that the holes are aligned with those of pieces B and C. Photo 6

Glue piece F to the same Side. Note that this piece does not require any spacer to be held in place. Photo 7

Step 8: Mounting the Framework III - the Tops

We will now mount the two top parts of the framework.


Take one of the two tops. To align correctly the sides before gluing the Tops, place a set square at one of the corners. Photo 1

Glue one of the Tops. Photo 2

Turn the piano upside down and glue the other top.

Photo 3: This is how the piano looks like after gluing all the parts.

Step 9: Preparing the LEDs and the Circuit

In this step, we will do the following activities:

1. Preparing the USB cable for the power supply
We will cut the USB cable and identify the (+) and (-) wires

2. Soldering the resistors and the LEDs
We will select the colored LEDs and we will solder them to the resistors

3. Placing the tubes and fibers in position
We will place the fibers and tubes at their proper position in the framework.

Preparing the USB cable for the power supply

The power of the piano will be supplied by a USB cable connected either to a phone charger, a power bank or a PC. In both cases, the USB port provides a voltage of 5V.

Cut the cable and remove the insulating black plastic around the little colored conductors. Photo 1

Typically, the power is supplied by the red and black cables. To check if this is true, and to identify the wire carrying the positive and negative voltage, we will use a multimeter. Photo 2

Make sure that the metallic tips of the wires are not touching each other. Connect the USB connector to a USB power supply and with the multimeter measure the voltage between the various cables. Two wires will have a voltage difference of 5 Volts. Find which cable has the positive voltage, and which has the negative one.

Cut and remove the wires that do not carry any voltage (green and white in photo 3&4).

Suggestion: keep the wires that you have just removed: they will be recycled in the next step to make the LED circuit. The longer the wire, the better.

Soldering the resistors and the LEDs

Select the colored LEDs of your piano; we will now solder them to the resistors. Before mounting the LEDs, we need to do the following:

(a) Identify the (+) and (-) connector of each LED
(b) calculate the resistance required for each LED
(c) weld the resistor to the (+) connector of each LED
(d) weld the LED in parallel, as in the circuit sketched in Step 1.

Photo 5 shows the future location of the LEDs. Each LED will be inserted in the hole corresponding to the fibers, in the order chosen in step 3.

Soldering the LEDs. The result should be similar to the detail shown in photo 6.

We can now connect the USB cable to the LEDs: connect the positive wire with the ( + ) line of the piano, and the negative to the ( - ). Photo 7

Placing the tubes and fibers in position

Take the acrylic tubes and the fibers. There should be one tube for each fiber. Place a rubber band around each acrylic tube.

Place each tube in one loop. And then slide the corresponding fiber through the hole of piece E and along all the tube. Photo 8

Fold the rubber band to the teeth of piece D as in photo 9 (top and bottom views).

The rubber band will hold the tube at one edge of the loop, in front of the corresponding LED. When you press the tube with your fingers, it will bend down. When you release the tube, the rubber band restore the tube back to its initial position. Photo 10

The rubber band has also a very important role: it keeps the LEDs and the circuit firmly fixed in their holes. Thanks to this trick, it is not necessary to glue the circuit, which can be easily removed if necessary. Photo 11


Note that the rubber bands can be folded to the in two positions:

1. So that the fibers are kept aligned with the holes adjacent to the loop
2. So that the fibers are not aligned with the holes adjacent to the loop

Photo 12, 13&14 show what the piano looks like when the USB cable is connected to the LEDs and to the power supply. All fibers are in front of the corresponding LED, so that the light goes through each fiber to its other end. In addition, the fibers used in this workshop are specially designed to glow when light is coupled into them.

When you press a key, the fiber is not in front of the LED any more, and light is not transmitted. The fiber does not glow any more, and light does not reach the other end of the fiber. Here you can find two examples. Photo 15


These instructions show how to build the piano so that the fibers are always illuminated by the light emitted by the LEDs, since they are aligned with the LEDs positions. When pressing down the tubes connected with the rubber bands, the fibers get misaligned and the emitted light cannot be coupled anymore in the fibers. We call this configuration as “normally on”.

In the first extension, we can build the piano in the “normally off” configuration: in this case the rubber bands are fixed in a position such that the fibers are not aligned with the holes adjacent to the loop. The photonic piano in its stand still configuration is not illuminated: only by pressing the tube the fibers get aligned with the LEDs and then become illuminated.


The piano as a carillon (Photo 16)
You can record your favorite melody by drilling holes in a piece of black paper, and sliding it into the thin slit at the top parts.


Coupling light with sound by a smartphone.

The goal of this extension is to couple the light switching process with sound. In particular the photonics piano works if a given note is produced once the corresponding illuminated fiber is switched off.

One way to get this is through the potentialities offered by smartphones, which can read an image and correspondingly generate a sound. A demo app for iOs has been developed to test the potentiality of this technique. It is sufficient to view the light spots with the camera of the smartphone or tablet, press the piano keys, and let the app translate the light pattern into sound. The app is configured to play both in the “Normally on” and “Normally off” configuration. The app “PhotonicPiano” is available in the Apple Store. Photo 17


Coupling light with sound by Arduino. (Arduino files attached)

The goal of this extension is again to couple the light switching process with sound. One possibility is to detect the light by photodiodes and to use the photodiode output signal to activate the playback of a selected sound through an Arduino board. The system is configured to play both in the “Normally off” configuration, even if it could be also modified to work in the “Normally on” configuration, which is less intuitive. Photo 18&19

Step 10: End Result & Conclusions

What we learned?

· Light propagation and diffusion in optical fibers
· Total internal reflection
· Working principles of LEDs
· Fablabs and their capabilities

Concluding thoughts

In this workshop a technology based on light and photonics is used to practically explore fundamental properties of light such as light propagation, total internal reflection, and diffusion and possible applications. This is done with a hands on approach aimed at the fabrication of a musical tool, the “photonic piano” where light can be switched on and off as one likes. The further coupling to sound through modern technology makes the project more challenging and appealing for the participants. The provided kit (which can be taken home by participants) and the acquired experience can be an inspiration for future original explorations and trials.

PHABLABS 4.0 is a European project where two major trends are combined into one powerful and ambitious innovation pathway for digitization of European industry: On the one hand the growing awareness of photonics as an important innovation driver and a key enabling technology towards a better society, and on the other hand the exploding network of vibrant Fab Labs where next-generation practical skills-based learning using KETs is core but where photonics is currently lacking.

This workshop was set up by the IFN CNR (Institute for Photonics and Nanotechnologies of the Italian National Research Council) in close collaboration with Fab Lab Milano and Muse Fablab Trento.