# Raspberry Pi Pico Piano – Part 3

JulianWong

In the previous chapter, we built a Raspberry Pi Pico Piano to play two notes simultaneously. If you haven't checked out that article, welcome to check it out (Raspberry Pi Pico Piano – Part 2). Then, in this chapter, we will move on to the hardware part.

We know that the output PWM signal of the Raspberry Pi Pico is a square wave. But in music, all notes are in Sine waves. To make it more likely a piano, in this chapter, I will share how I make a Square to Sine wave converter and an amplifier to amplify the output level.

First, let’s see how the output PWM signal by the Raspberry Pi Pico is. Below, I used an oscilloscope to measure the PWM signal by the Raspberry Pi Pico. We can see that there is a Sine wave outputted.

Then, I tried to use an RC Low Pass Filter to reject the high frequency.

After I put the first RC stage, we can see that the output signal becomes more like a sine wave, which is an excellent start to making it a real piano.

Let’s try to implement the second RC stage to see whether the output signal can become more like a sine wave.

The output sine wave looks better. But having it as a sine wave still goes a long way. Let’s add one more RC stage.

Now, we can observe a perfect sine wave. However, the trade-off is that we reduce the output signal level.

To calculate the output signal, the output signal will be reduced for each RC stage.

Hence, we need to think about how to amplify the output signal.

For the amplifier part, I chose the LM386 RS Stock No: . LM386 is a low voltage audio power amplifier. In this project, I directly used a USB for the power source for the amplifier, which means 5V input. For the circuit design, I followed the datasheet, which has a circuit diagram of LM386 with Gain = 50. The load impedance is 4 Ω to 32 Ω and the supply voltage is 5V to 12V.