Arduino 在何处输入5*5按钮矩阵的代码,以控制5*5 Led矩阵,该矩阵以正方形的形式亮起

Arduino 在何处输入5*5按钮矩阵的代码,以控制5*5 Led矩阵,该矩阵以正方形的形式亮起,arduino,arduino-uno,arduino-ide,arduino-esp8266,Arduino,Arduino Uno,Arduino Ide,Arduino Esp8266,我希望5*5 Led矩阵中的Led以正方形的形式亮起。如果按下5*5按钮矩阵中的相应按钮,led将熄灭。从左上方的第一个按钮开始按顺时针方向按下按钮。我使用Arduino Uno作为程序员,Arduino-Mega2560作为目标,5*5 Led矩阵和5*5按钮矩阵连接到Arduino-Mega2560。我有5*5 Led矩阵的代码,它以正方形的形式亮起作为单独的代码,5*5按钮矩阵作为单独的代码,其中输入5*5按钮矩阵的代码来控制5*5 Led矩阵,如上所述。谢谢 5*5 Led矩阵以正方形亮

我希望5*5 Led矩阵中的Led以正方形的形式亮起。如果按下5*5按钮矩阵中的相应按钮,led将熄灭。从左上方的第一个按钮开始按顺时针方向按下按钮。我使用Arduino Uno作为程序员,Arduino-Mega2560作为目标,5*5 Led矩阵和5*5按钮矩阵连接到Arduino-Mega2560。我有5*5 Led矩阵的代码,它以正方形的形式亮起作为单独的代码,5*5按钮矩阵作为单独的代码,其中输入5*5按钮矩阵的代码来控制5*5 Led矩阵,如上所述。谢谢

5*5 Led矩阵以正方形亮起的代码

#define MAXLEDS 5
int states[MAXLEDS][MAXLEDS] = {
    { 1, 1, 1 ,1 ,1 },
    { 1, 0, 0 ,0 ,1 },
    { 1, 0, 0, 0 ,1 },
    { 1, 0, 0, 0 ,1 },
    { 1, 1, 1, 1 ,1 },

};
int Led_Row_Pins[] = { 2 , 3 , 4 , 5 , 6 } ;             //   Anode pins are shorted in row_wise_manner
int Led_Column_Pins[] = {7 , 8 , 9 , 10 , 11 } ;          //   Column Pins are shorted in column_wise_manner   
int Loop_Count = 5 ;
int i = 0 ;
int j = 0 ;
int state = 1 ;

void setup() {
  for( i = 0 ; i < Loop_Count ; i++ ){     // Anode Pins are connected in row_wise manner and are made LOW so that they dont conduct       
    pinMode(Led_Row_Pins[i],OUTPUT);
    digitalWrite(Led_Row_Pins[i],LOW);
    pinMode(Led_Column_Pins[i],OUTPUT);    // Cathode Pins are connected in column_wise manner and are made HIGH so that they dont conduct
    digitalWrite(Led_Column_Pins[i],HIGH); 
  }
}


void switch_leds(int row) {
    int i;

    /* switch off all rows */
    for(i = 0; i < MAXLEDS; i++) {
        digitalWrite(Led_Row_Pins[i], 0);
    }

    /* switch columns according to current row */
    for(i = 0; i < MAXLEDS; i++) {
        digitalWrite(Led_Column_Pins[i], !states[row][i]);
    }

    /* switch on current row */
    digitalWrite(Led_Row_Pins[row], 1);

}

void loop() { 
    static int row = 0;
    /* switch on LEDs in a single row */
    switch_leds(row);
    /* next row */
    row++; row %= MAXLEDS;
    /* The processing delay between calls to loop() is added to this delay. */
    delay(5);
}
#定义最大发光二极管5
int状态[MAXLEDS][MAXLEDS]={
{ 1, 1, 1 ,1 ,1 },
{ 1, 0, 0 ,0 ,1 },
{ 1, 0, 0, 0 ,1 },
{ 1, 0, 0, 0 ,1 },
{ 1, 1, 1, 1 ,1 },
};
int Led_行_引脚[]={2,3,4,5,6};//阳极引脚以行方式短路
int Led_列_管脚[]={7,8,9,10,11};//柱销以柱状方式短路
int循环计数=5;
int i=0;
int j=0;
int state=1;
无效设置(){
对于(i=0;i
5*5按钮矩阵的代码为

#include <Keypad.h>

const byte ROWS = 5; 
const byte COLS = 5; 

char hexaKeys[ROWS][COLS] = {
  {'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'},

};

byte rowPins[ROWS] = { 40, 39 , 38 , 37  ,36 }; 
byte colPins[COLS] = { 35  , 34  , 33  , 32 , 31 };  

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);
}
#包括
常量字节行=5;
常量字节COLS=5;
字符六键[行][COLS]={
{'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'},
};
字节rowPins[行]={40,39,38,37,36};
字节colPins[COLS]={35,34,33,32,31};
Keypad customKeypad=键盘(makeyMap(六键)、行PIN、列PIN、行、列);
无效设置(){
Serial.begin(9600);
}
void循环(){
char customKey=customKeypad.getKey();
如果(自定义键)
Serial.println(customKey);
}

您想要“…”,但问题是什么?你的问题是什么?除了一个按需要运行的程序外,您还希望得到什么帮助?如果您使用的是arduino Mega,为什么这个标记为arduino-esp8266?了解代码a),了解代码b),然后合并它们。就这样。如果你只是问如何合并它们,你什么也学不到。@Pigget抱歉,先生,将来肯定不会这么做。是什么阻止你自己解决这个问题?你无法独自完成的第一步是什么?