#4 Piano Project With micro:bit
Advancements in electronics have led to the digitization of music instruments that were difficult and expensive to produce. Pianos are at the forefront of these instruments. Each key of digital pianos generates electrical signals at different frequencies, in this way, allowing them to play 88 different notes from their speakers. Factors such as the delay time of the keys on digital instruments, the quality of the speakers, and the resolution of the sound have emerged as quality-affecting elements. In electric guitars, vibrations on the strings are digitized instead of keys. In wind instruments, played notes can be converted into electrical signals and recorded through high-resolution microphones attached to the sound output. These developments in electronics have facilitated access to high-cost musical instruments and diversified music education.
In this project, we will create a touch-sensitive piano by using the PicoBricks Touch & Piano module.
We will use the PicoBricks Touch & Piano module to play the desired note on the buzzer of the Micro:Bit based on the touch sensor. We will print the value of the pressed note on the Micro:Bit Matrix LEDs, and we will also display the texts "PicoBricks" and "Piano" on the PicoBricks OLED screen.
Connection Diagram:
You can prepare this project by breaking the PicoBricks modules at the proper points.

Project Images:
![]() |
![]() |
MakeCode Code of The Project
Python Code of The Project:
from microbit import * from touchsensor import * touchsensor = CY8CMBR3116() touchsensor.init() while True: touchsensor.PlayPiano() data = touchsensor.ReadButton() #print(data) if data == 7: display.show('C') elif data == 8: display.show('D') elif data == 9: display.show('E') elif data == 10: display.show('F') elif data == 11: display.show('G') elif data == 12: display.show('A') elif data == 13: display.show('B') elif data == 14: display.show('C')