'''
const int rows = 3;
const int collums = 2;
int selectionArray[rows][collums] =
{
{1, 30},
{2, 100}
};
'''
this is the code for the array
'''
int arraySearch(){
Serial.println("");
Serial.println("What would you like to open boot = 1 or door = 2: ");
while (Serial.available()==0){}
bootOrDoor = Serial.parseInt();
for (int i=0; i<3; i++) {
if (bootOrDoor == (selectionArray[i][0])){
Serial.println("distance needed");
targetDistance = (selectionArray[i][i]);
Serial.println(targetDistance);
}
}
return targetDistance;
'''
this is the code for searching the array
the code works how i want for the door when i input the number 2 i get an output of 100
however when i input the number 1 i get an output of 1 and i am unsure how to fix this any help would be appreciated
6 posts - 3 participants