An amazing piano made from 3D printing and piezo speakers! (Any speaker can be used)
Devices and components
Arduino-Nano
2 pin push button
Electric wire
Materials and tools
soldering iron
Prusa 3D printer
Software and tools
Arduino IDE
Project description
Yumee_PIANO
Adjust the code to your own wiring
1#define C 2093
2#define CS 2217
3#define D 2400
4#define DS 2500
5#define E 2602
6#define F 2745
7#define FS 3010
8#define G 3135
9#define GS 3322
10#define A 3520
11#define AS 3729
12#define B 3951
13
14#define HC 4186.01
15#define HCS 4435
16#define HD 4750
17#define HDS 4900
18#define HE 5275
19
20int noteDuration = 20;
21
22int Note_A = A;
23int Note_AS = AS;
24
25
26int Note_B = B;
27
28int Note_C = C;
29int Note_CS = CS;
30
31int Note_D = D;
32int Note_DS = DS;
33
34int Note_E = E;
35
36int Note_F = F;
37int Note_FS = FS;
38
39int Note_G = G;
40int Note_GS = GS;
41
42
43int Note_HC = HC;
44
45int Note_HCS = HCS;
46
47int Note_HD = HD;
48
49int Note_HDS = HDS;
50
51int Note_HE = HE;
52
53
54
55
56void setup() {
57 pinMode (2, INPUT_PULLUP);
58 pinMode (3, INPUT_PULLUP);
59 pinMode (4, INPUT_PULLUP);
60 pinMode (5, INPUT_PULLUP);
61 pinMode (6, INPUT_PULLUP);
62 pinMode (7, INPUT_PULLUP);
63 pinMode (8, INPUT_PULLUP);
64 pinMode (9, INPUT_PULLUP);
65
66Serial.begin(9600);
67
68}
69
70void loop() {
71
72 if(digitalRead(2) == LOW) {
73 Serial.println("HIGH");
74 tone (10, Note_C, noteDuration);
75 }
76
77 else {
78 noTone;
79 Serial.println("LOW");
80 }
81
82
83 if(digitalRead(3) == LOW) {
84 tone (10, Note_CS, noteDuration);
85 }
86
87 else {
88 noTone;
89 }
90
91
92 if(digitalRead(4) == LOW) {
93 tone (10, Note_D, noteDuration);
94 }
95
96 else {
97 noTone;
98 }
99
100
101 if(digitalRead(5) == LOW) {
102 tone (10, Note_DS, noteDuration);
103 }
104
105 else {
106 noTone;
107 }
108
109
110 if(digitalRead(6) == LOW) {
111 tone (10, Note_E, noteDuration);
112 }
113
114 else {
115 noTone;
116 }
117
118
119 if(digitalRead(7) == LOW) {
120 tone (10, Note_F, noteDuration);
121 }
122
123 else {
124 noTone;
125 }
126
127
128 if(digitalRead(8) == LOW) {
129 tone (10, Note_FS, noteDuration);
130 }
131
132 else {
133 noTone;
134 }
135
136 if(digitalRead(9) == LOW) {
137 tone (10, Note_G, noteDuration);
138 }
139
140 else {
141 noTone;
142 }
143
144
145
146}
147
148
149
150
151
152
153
154/* Code for second arduino
155
156
157
158#define C 2093
159#define CS 2217
160#define D 2400
161#define DS 2500
162#define E 2602
163#define F 2745
164#define FS 3010
165#define G 3135
166#define GS 3322
167#define A 3520
168#define AS 3729
169#define B 3951
170
171#define HC 4186.01
172#define HCS 4435
173#define HD 4750
174#define HDS 4900
175#define HE 5275
176
177int noteDuration = 20;
178
179int Note_A = A;
180int Note_AS = AS;
181
182int Note_B = B;
183
184int Note_C = C;
185int Note_CS = CS;
186
187int Note_D = D;
188int Note_DS = DS;
189
190int Note_E = E;
191
192int Note_F = F;
193int Note_FS = FS;
194
195int Note_G = G;
196int Note_GS = GS;
197
198
199int Note_HC = HC;
200int Note_HCS = HCS;
201
202int Note_HD = HD;
203int Note_HDS = HDS;
204
205
206
207
208void setup() {
209 pinMode (2, INPUT_PULLUP);
210 pinMode (3, INPUT_PULLUP);
211 pinMode (4, INPUT_PULLUP);
212 pinMode (5, INPUT_PULLUP);
213 pinMode (6, INPUT_PULLUP);
214 pinMode (7, INPUT_PULLUP);
215 pinMode (8, INPUT_PULLUP);
216 pinMode (9, INPUT_PULLUP);
217
218Serial.begin(9600);
219
220}
221
222void loop() {
223
224 if(digitalRead(2) == LOW) {
225 Serial.println("HIGH");
226 tone (12, Note_GS, noteDuration);
227 }
228
229 else {
230 noTone;
231 Serial.println("LOW");
232 }
233
234
235 if(digitalRead(3) == LOW) {
236 tone (12, Note_A, noteDuration);
237 }
238
239 else {
240 noTone;
241 }
242
243
244 if(digitalRead(4) == LOW) {
245 tone (12, Note_AS, noteDuration);
246 }
247
248 else {
249 noTone;
250 }
251
252
253 if(digitalRead(5) == LOW) {
254 tone (12, Note_B, noteDuration);
255 }
256
257 else {
258 noTone;
259 }
260
261
262 if(digitalRead(6) == LOW) {
263 tone (12, Note_BS, noteDuration);
264 }
265
266 else {
267 noTone;
268 }
269
270
271 if(digitalRead(7) == LOW) {
272 tone (12, Note_HC, noteDuration);
273 }
274
275 else {
276 noTone;
277 }
278
279
280 if(digitalRead(8) == LOW) {
281 tone (12, Note_HD, noteDuration);
282 }
283
284 else {
285 noTone;
286 }
287
288 if(digitalRead(9) == LOW) {
289 tone (12, Note_HDS, noteDuration);
290 }
291
292 else {
293 noTone;
294 }
295
296
297
298}
299
300*/
Downloadable files
Case CAD
Glorious Duup-Blorr (1) (2).stl
Keys CAD
Print sets separately for different colors
Glorious Duup-Blorr (2) (1).stl
Documentation
piano_schematic1
Original design
piano_schematic1.png
First soldered Arduino
piano_schem.jpg
Schematic
Connect digital pins as needed
Screenshot 2026-06-08 142556.png
Put it together!
Hot glue or tape
img_6633_TKbxMYqigL.jpg
Case Print Results
Remove media
img_6312_r2gxCDcM2p.jpg
Note: Content and images are from: https://projecthub.arduino.cc/, with some modifications.
If you want it removed due to copyright reasons, please leave a comment. Thank you.
I want to share this article more widely so that everyone knows about Arduino and your project.