|
void loop() {
Keypad.checkChanges(); // 更新键盘状态
if (Keypad.isKeyChanged()) { // 如果有新按键
KeyValue = Keypad.getKeyValue();
String6 = map (KeyValue,0,6,41,47);
String5 = map (KeyValue,7,13,46,52);
String4 = map (KeyValue,14,20,51,57);
String3 = map (KeyValue,21,27,56,62);
String2 = map (KeyValue,28,34,60,66);
String1 = map (KeyValue,35,41,65,71);
if (KeyValue >= 41 , KeyValue <= 47){
noteOn(0, String6, 120); // Channel, Note, Velocity
MidiUSB.flush();
Serial.print("Note Played: ");
Serial.println(String6);
Keypad.checkChanges();
}
if (KeyValue >= 46 , KeyValue <= 52){
noteOn(0, String5, 120); // Channel, Note, Velocity
MidiUSB.flush();
Serial.print("Note Played: ");
Serial.println(String5);
Keypad.checkChanges();
}
if (KeyValue >= 51 , KeyValue <= 57){
noteOn(0, String4, 120); // Channel, Note, Velocity
MidiUSB.flush();
Serial.print("Note Played: ");
Serial.println(String4);
Keypad.checkChanges();
}
if (KeyValue >= 56 , KeyValue <= 62){
noteOn(0, String3, 120); // Channel, Note, Velocity
MidiUSB.flush();
Serial.print("Note Played: ");
Serial.println(String3);
Keypad.checkChanges();
}
if (KeyValue >= 60 , KeyValue <= 66){
noteOn(0, String2, 120); // Channel, Note, Velocity
MidiUSB.flush();
Serial.print("Note Played: ");
Serial.println(String2);
Keypad.checkChanges();
}
if (KeyValue >= 65 , KeyValue <= 71){
noteOn(0, String1, 120); // Channel, Note, Velocity
MidiUSB.flush();
Serial.print("Note Played: ");
Serial.println(String1);
Keypad.checkChanges();
}
}
delay(10); // 延时 10ms
}
不能识别键值,或者输出的值不对,请问高手们,代码是不是有问题,谢谢了! |
|