0
int ColumnPins = 4; //How many column pins
int RowPins = 5; //How many row pins
int Columns[] = {0, 1, 2, 3}; //Column pinNumbers
int Rows[] = {4, 6, 7, 8, 9}; //Row pinNumbers
void setup()
{
pinMode(13, OUTPUT);
for (int counter = 0; counter < ColumnPins; counter++)
{ //set all the columns to output
pinMode(Columns[counter], OUTPUT);
}
for (int counter = 0; counter < RowPins; counter++)
{ //set all rows to input
pinMode(Rows[counter],INPUT_PULLDOWN);
}
}
void loop()
{
for (int ColumnIndex = 0; ColumnIndex < ColumnPins; ColumnIndex++) //sets column pins to high 1 by 1
{
digitalWrite(Columns[ColumnIndex], HIGH);
RowScan(ColumnIndex); //calls function rowscan checks whether and row is HIGH
digitalWrite(Columns[ColumnIndex], LOW);
}
}
void RowScan(int ColumnIndex) //Scans each rowpin and checks whether any reads high
{
for (int RowIndex = 0; RowIndex < RowPins; RowIndex++)
{
if (digitalRead(Rows[RowIndex]) == HIGH) //if Rows at rowindex is high
{
for (int blinks = 0; blinks <= RowIndex; blinks++)
{ //Outputs # of blinks based on which row HIGH was read
// print index
digitalWrite(13, HIGH); //LEDPIN high
delay(250);
digitalWrite(13, LOW);
delay(500);
}
for (int blinks = 0; blinks <= ColumnIndex; blinks++)
{ //Outputs # of blinks based on which row HIGH was read
// print index
digitalWrite(13, HIGH); //LEDPIN high
delay(100);
digitalWrite(13, LOW);
delay(100);
}
}
else if (digitalRead(Rows[RowIndex]) == LOW) //Rows at index o is LOW
{
digitalWrite(13,LOW);
}
}
}
C++의 Arduino IDE 컬럼 단지 설정된 열을 반환해야하는 경우는 가압 시간을 기준으로 0-3에서 임의의 값을 반환하는 가압 정확한 열 번호를 반환하지 행이 하이 일 때 하이로 void loop()의 첫 번째 for 루프에 문제가 있는지 확실히 알지 못합니다.키보드 매트릭스 코드는 버튼