Principle (see attached for engineering documents): Depending on the value of the external resistor, the 3rd pin (OUT) of the 555 timer can output square waves of different frequencies. The sound of the passive buzzer is related to the input frequency. Based on this principle, multiple resistors can be connected in series and switches can be added. By pressing different switches, the 555 timer will output the sound frequency of the corresponding note, and the seven basic notes can be sounded through the buzzer, thus realizing the production of a simple electronic piano with a 555 timer.
Steps: Determine the connection method of the 555 timer and drive the chip with a 5v power supply. In order to stabilize the circuit, a 0.01uf decoupling capacitor is connected to the 5th pin (COUT). Since the output frequency of the 555 timer is determined by the external resistor and capacitor, the capacitor is set to 100nf, and the pull-up resistor of the 7th discharge pin (DISCH) is set to 1k ohm, so only the resistance value between pins 2, 6 and 7 needs to be considered.
Buzzer module:
Use the existing module (sound frequency adjustable module) The IO port is connected to the OUT pin of the 555 timer.
The resistance calculation is as follows: Seven notes, Doremi Fasolasi, the frequency gradually increases, and the period decreases. According to the calculation formula T=0.7*(R1+2*R2)*C1, since R1 is a fixed value of 1k and C1 is 100nf, only the resistance of R2 needs to be considered. In the high pitch range, the corresponding frequencies of the seven notes are 1046.5Hz, 1174.66Hz, 1318.51Hz, 1396.92Hz, 1567.98Hz, 1760Hz, and 1975.52Hz. The total value of R2 corresponding to each note is calculated. Since the resistors are connected in series, the total resistance of each adjacent note needs to be calculated and interpolated as the resistance of each note. According to the above formula and the set frequency, the resistance values corresponding to the Doremi Fasolaxi are calculated to be 3100 ohms, 430 ohms, 470 ohms, 470 ohms, 410 ohms, 530 ohms, and 750 ohms.

Schematic diagram:

Simulation demonstration:
Do note:

Rui note:
Mi note:
Fa note:
Suo note:
La note:
Xi note: