255 / 5.000
Resultados de tradução
Resultado da tradução
Greetings to everyone, I'm new to the world of Arduino but I successfully managed to bring my old Casio Ct 670 back to life by transforming it into a MiDI controller, the question is, is there any way to include the pithbend to work together? Below is the code used..
#include <MIDI.h>
#include <Keypad.h>
const byte ROWS = 11; // 11 Linhas
const byte COLS = 6; // 6 Colunas
char keys[COLS][ROWS] = {
{24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34},
{35, 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}
};
byte rowPins[ROWS] = {2, 3, 4, 5, 6, 13, A0, A1, A2, A3, A4}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {7,8,9,10,11,12}; //connect to the column pinouts of the kpd
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
byte pressed = 32;
byte chanel = 0; // MIDI channel to use
void setup() {
Serial.begin(115200); // set this the same as Hairless
}
void loop() {
// Fills kpd.key[49] array with up-to 10 active keys.
// Returns true if there are ANY active keys.
if (kpd.getKeys())
{
for (int i = 0; i < LIST_MAX; i++) // Scan the whole key list.
{
if ( kpd.key[i].stateChanged ) // Only find keys that have changed state.
{
pressed = kpd.key[i].kchar + 12;
switch (kpd.key[i].kstate) { // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
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);
}