hi, I wrote a code that sets the values of a few arrays and then compares them but it seems to not be working correctly, I expected the code to print "false password" because I set the buttons[] to 0 and the passTrue to 1, and so the comparing function (CheckPass) should output "false password", instead I am getting am infinite line of "÷". any help would be appreciated. below is my code.
int i;
int passTrue[9];
int buttons[] {};
int * SetButtons() {
for (int i = 1; i<=9; ++i) {
buttons[i] = digitalRead(i);
return buttons;
}
}
void setup() {
Serial.begin(9600);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10,INPUT_PULLUP);
pinMode(13, OUTPUT);
}
int * SetPass() {
i = 0;
for (i = 1; i<=9; ++i) {
if(buttons[i] == LOW) {
passTrue[i] = buttons[i];
}
}
return passTrue;
}
void CheckPass() {
for(i=1; i<=9; ++i) {
if(passTrue[i] != buttons[i]) {
Serial.println("false Password");
}
}
}
void Test() {
for(i=1; i<=9; ++i) {
buttons[i] = 0;
passTrue[i] = 1;
}
}
void loop() {
SetButtons();
SetPass();
Test();
CheckPass();
}