I wrote this code to scan 24 keys matrix, it's work great with Arduino Uno but on teensy 3.2 and 3.6 I got something like "double pulsing".
when I press on the 7th' key I got 6 and 7 reading , allmost same when I pressed the 16th' key then I got 14 and 16 reading.
all the rest of the keys works fine.
thanks for help ,
the code :
when I press on the 7th' key I got 6 and 7 reading , allmost same when I pressed the 16th' key then I got 14 and 16 reading.
all the rest of the keys works fine.
thanks for help ,
the code :
Code:
int pressedKey[25]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int k1_row[6]={1,2,3,4,5,6};
int k1_col[4]={7,8,9,10};
void setup() {
Serial.begin(9600);
delay(1000);
for(int i=0;i<=5;i++){
pinMode(k1_row[i],OUTPUT);
}
for(int i=0;i<=3;i++){
pinMode(k1_col[i],INPUT_PULLUP);
}
Serial.println("SETUP DONE");
}
void loop() {
for(int i=0; i<=5; i++){
digitalWriteFast(k1_row[0],HIGH);
digitalWriteFast(k1_row[1],HIGH);
digitalWriteFast(k1_row[2],HIGH);
digitalWriteFast(k1_row[3],HIGH);
digitalWriteFast(k1_row[4],HIGH);
digitalWriteFast(k1_row[5],HIGH);
digitalWriteFast(k1_row[i],LOW);
for(int j=0; j<=3; j++){
int strokedKey=i*4+j+1;
bool col_scan=digitalRead(k1_col[j]);
if(col_scan==LOW){
if (pressedKey[strokedKey]==0 ){
//playMusic(strokedKey);
pressedKey[strokedKey]=1 ;
Serial.println(strokedKey);
}
delay(10);
}
else
pressedKey[strokedKey]=0;
}
delay(10);
}
}
Attachments
Last edited: