This project uses the contact sensor and the speaker actuator to make the keys to a piano.
How does it work?
Each pin will be connected to a note on the piano. A0 will be left for the speaker pin.
The method to making the keys is drawn on the left. This is applying the contact sensor card and shifting it slightly to fit the purpose of the piano keys. In the example card, the user will lift up the tab and connect the two circuits together. In this case, the user will press down to connect the circuits.
Putting it all together
The speaker pin will be connected the same way as the example speaker card. Inside a grand piano outline, the direction of the copper tape had to be adjusted so that everything will fit inside.
Once you have all the connections completed and speaker attached, upload the code to the CPX. The link contains the code for the piano: https://makecode.com/_MTA6w03sLfdA
After you have uploaded the code, you’re all done to play your DIY piano!