Go Down

Topic: MIDI KEYBOARD (Read 102 times) previous topic - next topic

Rezotsiklauri

hello guys, i was building midi keyboard. i found you code here on forum




#include <Keypad.h>

const byte ROWS = 8; //eight rows
const byte COLS = 8; //eight columns

char hexaKeys[COLS][ROWS] = {
  {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'},
  {'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'},
  {'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X'},
  {'Y', 'Z', '0', '1', '2', '3', '4', '5'},
  {'6', '7', '8', '9', 'a', 'b', 'c', 'd'},
  {'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'},
  {'m', 'n', 'o', 'p', 'q', 'r', 's', 't'},
  {'u', 'v', 'w', 'x', 'y', 'z', '!', '@'}
};
byte colPins[ROWS] = {5, 6, 7, 8, 9, 10, 11, 12}; //connect to the row pinouts of the keypad
byte rowPins[COLS] = {A0, A1, A2, A3, A4, A5, A6, A7}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup() {
  Serial.begin(9600);
}

void loop() {
  char customKey = customKeypad.getKey();

  if (customKey) {
    Serial.println(customKey);
  }
}


 but i have 6 row and 8 cols: 6 in digital and 8 in analog,also i want to add release and MIDI USB code, i am trying to modify code but i can't. please can you guys help me out. thanks in advance

Railroader

You can start by modifying this
Code: [Select]
const byte ROWS = 8; //eight rows
const byte COLS = 8; //eight columns
Use Your knowledge. If that's not enough, look for education.
Having knowledge, think outside the box to gain more of it. Only trains run like the train, on the rails. The rest run between the rails.

Rezotsiklauri

I did but it says error: too many initializers for 'char [6]' even if i delete last two rows, if i do wrong i'm just rookie sorry

Railroader

Attache the error report. Use code tags. To be sure, attache the code,
Use Your knowledge. If that's not enough, look for education.
Having knowledge, think outside the box to gain more of it. Only trains run like the train, on the rails. The rest run between the rails.

Rezotsiklauri

#4
Jan 16, 2020, 10:17 pm Last Edit: Jan 16, 2020, 10:18 pm by Rezotsiklauri
#include <Keypad.h>

const byte ROWS = 6; //six rows
const byte COLS = 8; //eight columns

char hexaKeys[COLS][ROWS] = {
  {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'},
  {'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'},
  {'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X'},
  {'Y', 'Z', '0', '1', '2', '3', '4', '5'},
  {'6', '7', '8', '9', 'a', 'b', 'c', 'd'},
  {'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'},
};
byte colPins[ROWS] = {5, 6, 7, 8, 9, 10}; //connect to the row pinouts of the keypad
byte rowPins[COLS] = {A0, A1, A2, A3, A4, A5, A6, A7}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup() {
  Serial.begin(9600);
}

void loop() {
  char customKey = customKeypad.getKey();

  if (customKey) {
    Serial.println(customKey);
  }
}


this is the code i modified and error message is


Arduino: 1.8.10 (Mac OS X), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

sketch_jan17a:13:1: error: too many initializers for 'char [6]'
 };
 ^
sketch_jan17a:13:1: error: too many initializers for 'char [6]'
sketch_jan17a:13:1: error: too many initializers for 'char [6]'
sketch_jan17a:13:1: error: too many initializers for 'char [6]'
sketch_jan17a:13:1: error: too many initializers for 'char [6]'
sketch_jan17a:13:1: error: too many initializers for 'char [6]'
sketch_jan17a:14:48: error: too many initializers for 'byte [6] {aka unsigned char [6]}'
 byte colPins[ROWS] = {5, 6, 7, 8, 9, 10, 11, 12}; //connect to the row pinouts of the keypad
                                                ^
Multiple libraries were found for "Keypad.h"
 Used: /Users/macbook/Documents/Arduino/libraries/Keypad
exit status 1
too many initializers for 'char [6]'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Railroader

You works too fast.

Check this:
Code: [Select]
const byte ROWS = 6; //six rows



Code: [Select]
byte colPins[ROWS] = {5, 6, 7, 8, 9, 10, 11, 12}; //connect to the row pinouts of the keypad
                                                ^


And, please, use code tags, up, to left inthis window.

Use Your knowledge. If that's not enough, look for education.
Having knowledge, think outside the box to gain more of it. Only trains run like the train, on the rails. The rest run between the rails.

Rezotsiklauri

Still the same error, too many initializers for 'char[6]'

Railroader

What changes did You make reading my answer?
Code and error report, using code tags please.
Use Your knowledge. If that's not enough, look for education.
Having knowledge, think outside the box to gain more of it. Only trains run like the train, on the rails. The rest run between the rails.

Rezotsiklauri

#8
Jan 16, 2020, 11:08 pm Last Edit: Jan 16, 2020, 11:15 pm by Rezotsiklauri
i just copied your code as i said i don't a word in programing, i can't get service and can't learn, cause it's too hard for me. i am just musician and want build simple MIDI keyboard, when i started this project i didn't know it could take this amount of time and also i didn't want to bother someone. like you guys on forum.

Code: [Select]

#include <Keypad.h>

const byte ROWS = 6; //six rows
const byte COLS = 8; //eight columns

char hexaKeys[COLS][ROWS] = {
{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'},
{'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'},
{'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X'},
{'Y', 'Z', '0', '1', '2', '3', '4', '5'},
{'6', '7', '8', '9', 'a', 'b', 'c', 'd'},
{'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'}
};
byte colPins[ROWS] = {5, 6, 7, 8, 9, 10, 11, 12}; //connect to the row pinouts of the keypad
byte rowPins[COLS] = {A0, A1, A2, A3, A4, A5, A6, A7}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup() {
Serial.begin(9600);
}

void loop() {
char customKey = customKeypad.getKey();

if (customKey) {
  Serial.println(customKey);
}
}



error message:Arduino: 1.8.10 (Mac OS X), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

sketch_jan17a:13:1: error: too many initializers for 'char [6]'
};
^
sketch_jan17a:13:1: error: too many initializers for 'char [6]'
sketch_jan17a:13:1: error: too many initializers for 'char [6]'
sketch_jan17a:13:1: error: too many initializers for 'char [6]'
sketch_jan17a:13:1: error: too many initializers for 'char [6]'
sketch_jan17a:13:1: error: too many initializers for 'char [6]'
sketch_jan17a:14:48: error: too many initializers for 'byte [6] {aka unsigned char [6]}'
byte colPins[ROWS] = {5, 6, 7, 8, 9, 10, 11, 12}; //connect to the row pinouts of the keypad
                                              ^
Multiple libraries were found for "Keypad.h"
Used: /Users/macbook/Documents/Arduino/libraries/Keypad
exit status 1
too many initializers for 'char [6]'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Railroader

Okey. Maybe You can find a coding experienced friend to help You. I will not read and penetrate Your entire code.

If You read my previous answer again You will see that You defined "ROWS" to contain 6 elements. Then You try to push 8 elements into that array sized for 6.


Use Your knowledge. If that's not enough, look for education.
Having knowledge, think outside the box to gain more of it. Only trains run like the train, on the rails. The rest run between the rails.

Rezotsiklauri

Yes you absolutely right, i can't understand any words. thank you, it's my fault i couldn't understand anything.

Railroader

The business of coding is fun for a lot of people. They enjoy learning, correcting errors, until the projet works. Other members just want their stuff to work. I don't want to be rude, to be ruff, but either You pick up the work of learning some coding or You go to the "toy shop", buying ready equipment.

Myself I once spent a hole year, changing the code, rebuilding the hardware in order to make it work. Then, suddenly, I woke up in the middle of night and new, remembered a hardware signal I left out 3 years earlier.
Use Your knowledge. If that's not enough, look for education.
Having knowledge, think outside the box to gain more of it. Only trains run like the train, on the rails. The rest run between the rails.

Go Up