I am using an uno with 1.5.6 and I have a question about my code, i am trying to have the Serial print out a 2d array of 0's and using a function change the numbers in the array. I have tried using nested for loops with arrays, but they take up to much memory so i am going with a class attempt
class enter{
private:
int right;
int left;
public:
enter(){
}
enter(int y,int x){
right=y;
left=x;
}
int getRight(){
return right;
}
int getLeft(){
return left;
}
boolean check(int y,int x){//checks where the point is
if(right==y&&left==x){
return true;
}
else{
return false;
}
}
};
void setup() {
Serial.begin(9600); // put your setup code here, to run once:
}
void loop() {
for (int p = 0; p < 10; p++) {
for (int i = 0; i < 15; i++) {
// client.print(array[p][i]);
// client.print("|");
Serial.print("0");
Serial.print("|");
}
//client.println("
");
Serial.println();
}
Serial.println("break");
enter b(2,3);// says there is a 4 at point 2,3
for (int p = 0; p < 10; p++) {
for (int i = 0; i < 15; i++) {
// client.print(array[p][i]);
// client.print("|");
if(b.check(p,i)){
Serial.print("4");
Serial.print("|");
}
else{
Serial.print("0");
Serial.print("|");
}
}
//client.println("
");
Serial.println();
}
Serial.println("done");
}
The issue i am having is that i do not know how this would work with a variable number of enter objects, which is my intended goal, are there any solutions to my problem or should i try another approach at this.