hi...
I'm very interested in your code, but here I also have a code for a keyboard or piano, with a standard number of 61 keys, and I also have a separate code specifically for pitch bend, which I want to ask, how do I combine it into These 2 codes, I really hope for all of my friends' help
and this is my code...
#include <MIDI.h>
#include <Keypad.h>
const byte ROWS = 8; //turun
const byte COLS = 8; //samping
char keys[COLS][ROWS] = {
{36, 37, 38, 39, 40, 41, 42, 43},
{44, 45, 46, 47, 48, 49, 50, 51},
{52, 53, 54, 55, 56, 57, 58, 59},
{60, 61, 62, 63, 64, 65, 66, 67},
{68, 69, 70, 71, 72, 73, 74, 75},
{76, 77, 78, 79, 80, 81, 82, 83},
{84, 85, 86, 87, 88, 89, 90, 91},
{92, 93, 94, 95, 96, 97, 98, 99}
};
byte rowPins[ROWS] = {2, 3, 4, 5, 6, 7, 8, 9};
byte colPins[COLS] = {A0, A1, A2, A3, A4, A5, 10, A7};
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
byte pressed = 32;
byte chanel = 0;
void setup() {
Serial.begin(115200);}
void loop() {
if (kpd.getKeys()){
for (int i = 0; i < LIST_MAX; i++) {
if ( kpd.key[i].stateChanged ) {
pressed = kpd.key[i].kchar + 0; // 0 61key C // 12 49key F //
switch (kpd.key[i].kstate) {
case PRESSED:
sendMIDI(chanel | 0x90, pressed, 100);
break;
case RELEASED:
sendMIDI(chanel | 0x80, pressed, 64);
break;
}
}
}
}
} // End loop
void sendMIDI(byte type, byte note, byte velocity){
Serial.write(type);
Serial.write(note & 0x7F);
Serial.write(velocity);}
and this is the code for the pitch bend.....
#include <MIDIUSB.h> // include MIDIUSB library
#include <pitchToNote.h> //
int joyX = 0; //Pitch Bend
int joyY = 0; //CC1 und CC20
int pitchBend = 0;
int controllerWert = 0;
int button = LOW;
int buttonAlt = LOW;
int schalter = 0;
void setup() {
//Serial.begin(9600);} //hairless-midiserial
Serial.begin(31250);} //Midi arduino 16u2
void loop() {
joystickAbfragen();
buttonAbfragen();
}
void joystickAbfragen() {
joyX = analogRead(A0);
if (joyX > 536) {
pitchBend = map(joyX,530,1023,65,127);
sendeMIDI(224,0,pitchBend);
}
if (joyX < 400) {
pitchBend = map(joyX,0,520,0,63);
sendeMIDI(224,0,pitchBend);
}
else if ((joyX > 520 && joyX < 530) && pitchBend != 64) {
pitchBend = 64;
sendeMIDI(224,0,pitchBend);
}
joyY = analogRead(A1);
if (joyY > 528) {
controllerWert = map(joyY,530,1023,0,127);
sendeMIDI(176,1,controllerWert);
}
else if (joyY < 520) {
controllerWert = map(joyY,520,0,0,127);
}
}
void buttonAbfragen() {
if (button == LOW && buttonAlt == HIGH) {
if(schalter == 0){
sendeMIDI(176, 64, 127);
schalter = 1;
}
else {
sendeMIDI(176, 64, 0);
schalter = 0;
}
}
buttonAlt = button;
}
void sendeMIDI(int statusByte, int dataByte1, int dataByte2) {
Serial.write(statusByte);
Serial.write(dataByte1);
Serial.write(dataByte2);
}
and please help me, because I'm having a lot of trouble, combining these 2 codes, I really hope, I can get the solution here
Your topic was moved to its current location as it is more suitable.
Could you also take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Thank you
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.