Skip to content

Commit bca06dd

Browse files
committed
Update MIDIUSB_oneKeyPiano.ino
1 parent faeeb8c commit bca06dd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

MIDI_examples/MIDIUSB_oneKeyPiano/MIDIUSB_oneKeyPiano.ino

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@
1818
int lastButtonState = HIGH;
1919

2020
void setup() {
21-
pinMode(5, INPUT);
21+
pinMode(5, INPUT_PULLUP);
2222
}
2323

2424
void loop() {
2525
int buttonState = digitalRead(5);
26+
int pitch = analogRead(A0) /8;
2627
if (buttonState != lastButtonState) {
2728
delay(5);
28-
if (buttonState == HIGH) {
29-
midiCommand(0x90, 0x45, 0x7F);
29+
if (buttonState == LOW) {
30+
midiCommand(0x90, pitch, 0x7F);
3031
} else {
3132
// turn the note off:
32-
midiCommand(0x80, 0x45, 0);
33+
midiCommand(0x80, pitch, 0);
3334
}
3435
// save the current state as the previous state
3536
// for the next comparison:

0 commit comments

Comments
 (0)