Hi Guys, sorry Im so bad at posting, my new job started recently and they are keeping me there quite late at the moment.
So this is what Ive written, I know the array (mstanley) isnt unsigned integers, I just wanted to do it from first principles and see how far I got. I think Im almost there?
const byte ROWS = 2; //four rows
const byte COLS = 4; //three columns
int buttonstate [ROWS][COLS] = {
{
0,0, 0, 0 }
,
{
0,0, 0, 0 }
};
byte colPins[COLS] = {
22, 23, 24, 25}; //connect to the row pinouts of the keypad
byte rowPins[ROWS] = {
5, 6}; //connect to the column pinouts of the keypad
void setup()
{
pinMode(rowPins[0], OUTPUT);
pinMode(rowPins[1], OUTPUT);//can be increased
for (int i = 0; i < COLS; i++){
pinMode(colPins[i], INPUT);
}
Serial.begin(19200);
}
void loop(){
for (int i = 0;i<ROWS;i++){
digitalWrite(rowPins[i], HIGH);
for (int j = 0; j<COLS;j++){
buttonstate[j][i] = digitalRead(colPins[j]);
Serial.print(buttonstate[j][i]);
Serial.print(",");
}
Serial.println("");
digitalWrite(rowPins[i], LOW);
}
Serial.println("");
}
so that compiles and everything, but I get odd output:
1,1,1,1,
0,0,0,0,0,0,0,0,
0,0,1,1,1,1,1,1,
0,0,0,0,0,0,1,1,
1,0,1,1,0,0,0,0,
0,0,0,0,0,0,1,1,
1,0,1,1,0,0,0,0,
0,0,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,
0,0,1,1,1,1,1,1,
0,0,0,0,0,0,1,1,
1,0,1,1,0,0,0,0,
0,0,0,0,0,0,1,1,
1,0,1,1,0,0,0,0,
0,0,1,1,1,1,1,1,
0,0,0,0,
Thats when Im not pressing any buttons at all. Just letting the loop run. When I do press buttons nothing seems to happen. Can anyone spot if Im doing something stupid?
Thanks
As a side question, once I have got this working, can I just map the state of each positon in the array to a midi signal and output that?