Hey guys. I'm new to programming with Arduino and I wanted to experiment by creating an LED matrix on Tinkercad circuits. It looks like this (Imgur: The magic of the Internet). I basically want to have preset patterns that the arduino can write to the matrix. (for now, there is just one pattern called "CubePattern"). The ChangePattern function basically goes through each row and column of a pattern(For now just CubePattern) and decide if it should be on or not. However, I keep getting an error at at the line:
"if (Pattern[ThisRow][ThisColumn]==1){"
This line is basically trying to index an array inside an array and check if it's 1. (I hope I worded that correctly)
The error says:
In function 'int ChangePattern(int*)':
60:38: error: invalid types 'int[int]' for array subscript
I've tried and researched a bunch of things and nothing has worked. It is likely something obvious but I'm new to this so I'd appreciate the help. Thanks! Also, if there's anything else I can improve about the code let me know!
int ledpins[8]{1,2,3,4,5,6,7,8};
int CollumnPins[4]{1,2,3,4}; //Negative
int RowPins[4]{5,6,7,8};//Positive
// the setup routine runs once when you press reset:
void setup() {
for (int thisPin = 1; thisPin < 4; thisPin++) { //Turn all Column pins on high
pinMode(ColumnPins[thisPin], OUTPUT);
digitalWrite(ColumnPins[thisPin],HIGH);
}
for (int thisPin = 5; thisPin < 8; thisPin++) { //Turn all Row pins on low
pinMode(RowPins[thisPin], OUTPUT);
digitalWrite(RowPins[thisPin],LOW);
}
}
void loop() {
int CubePattern[4][4] = { //A pattern that I want to have on the LED matrix, 1's being on, 0's being off
{0, 0, 0, 0},
{0, 1, 1, 0},
{0, 1, 1, 0},
{0, 0, 0, 0}
};
ChangePattern(CubePattern[4]);
}
int ChangePattern(int Pattern[4]){ //write pattern on Matrix
for (int ThisRow = 1; ThisRow < 4; ThisRow++) { //Negative.
for (int ThisColumn = 4; ThisColumn < 8; ThisColumn++) {
if (Pattern[ThisRow][ThisColumn]==1){ //LINE THAT GIVES THE ERROR
digitalWrite(ThisRow, HIGH);
digitalWrite(ThisColumn, LOW);
}
}
}
}