garyocampo
New member
Hi, i'm currently adapting an 88 key piano I found in the trash to a teensy.
I found the multikey example in the keypad library and thought it would be useful for my purposes.
here is my code:
and here is my error
now I understand that the keys are intended to be in single quotes like so {'a', 'b', 'c'} but since I have 88 keys i thought id use double quotes (the documentation allows it).
I have 11 columns and I initialize 11 pins.
thanks in advance for any help, if i have forgoten something please let me know.
cheers!!!
I found the multikey example in the keypad library and thought it would be useful for my purposes.
here is my code:
HTML:
/* @file MultiKey.ino
|| @version 1.0
|| @author Mark Stanley
|| @contact mstanley@technologist.com
||
|| @description
|| | The latest version, 3.0, of the keypad library supports up to 10
|| | active keys all being pressed at the same time. This sketch is an
|| | example of how you can get multiple key presses from a keypad or
|| | keyboard.
|| #
*/
#include <Keypad.h>
const byte ROWS = 8; //four rows
const byte COLS = 11; //three columns
char keys[ROWS][COLS] = {
{"A0","A1","A2","A3","A4","A5","A6","A7","A8","A9","A10"},
{"B0","B1","B2","B3","B4","B5","B6","B7","B8","B9","B10"},
{"C0","C1","C2","C3","C4","C5","C6","C7","C8","C9","C10"},
{"D0","D1","D2","D3","D4","D5","D6","D7","D8","D9","D10"},
{"E0","E1","E2","E3","E4","E5","E6","E7","E8","E9","E10"},
{"F0","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10"},
{"G0","G1","G2","G3","G4","G5","G6","G7","G8","G9","G10"},
{"H0","H1","H2","H3","H4","H5","H6","H7","H8","H9","H10"}
};
byte rowPins[ROWS] = {0, 1, 2, 3, 4, 5, 6, 7}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28}; //connect to the column pinouts of the kpd
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
unsigned long loopCount;
unsigned long startTime;
String msg;
void setup() {
Serial.begin(9600);
loopCount = 0;
startTime = millis();
msg = "";
}
void loop() {
loopCount++;
if ( (millis()-startTime)>5000 ) {
Serial.print("Average loops per second = ");
Serial.println(loopCount/5);
startTime = millis();
loopCount = 0;
}
// Fills kpd.key[ ] 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.
{
switch (kpd.key[i].kstate) { // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
case PRESSED:
msg = " PRESSED.";
break;
case HOLD:
msg = " HOLD.";
break;
case RELEASED:
msg = " RELEASED.";
break;
case IDLE:
msg = " IDLE.";
}
Serial.print("Key ");
Serial.print(kpd.key[i].kchar);
Serial.println(msg);
}
}
}
} // End loop
and here is my error
HTML:
MultiKey:27: error: too many initializers for 'char [11]'
};
^
MultiKey:27: error: too many initializers for 'char [11]'
MultiKey:27: error: too many initializers for 'char [11]'
MultiKey:27: error: too many initializers for 'char [11]'
MultiKey:27: error: too many initializers for 'char [11]'
MultiKey:27: error: too many initializers for 'char [11]'
MultiKey:27: error: too many initializers for 'char [11]'
MultiKey:27: error: too many initializers for 'char [11]'
too many initializers for 'char [11]'
now I understand that the keys are intended to be in single quotes like so {'a', 'b', 'c'} but since I have 88 keys i thought id use double quotes (the documentation allows it).
I have 11 columns and I initialize 11 pins.
thanks in advance for any help, if i have forgoten something please let me know.
cheers!!!