Play two different notes with buttons.
/* two_note_keyboard */ int speaker = 9; int button1 = 2; int button2 = 4; int note1 = 262; int note2 = 294; int value1, value2; void setup() { pinMode(speaker, OUTPUT); pinMode(button1, INPUT); pinMode(button2, INPUT); } void loop() { value1 = digitalRead(button1); value2 = digitalRead(button2); while (value1 == HIGH || value2 == HIGH) { while (value1 == HIGH) { tone(speaker, note1, 20); value1 = digitalRead(button1); } while (value2 == HIGH) { tone(speaker, note2, 20); value2 = digitalRead(button2); } } }