Getting error code macro "isConnected" passed 2 arguments, but just takes 0

Hello All,

I am having trouble understanding what this error code means, and why it could be happening. I took a deeper step into programming by learning arrays, but when I got this message, I am just confused about what to do now. They may be more issues further down, I am not sure yet, the verify tool just got stuck here.

Thanks

 bool currentState = isConnected(pin1, pin2);

Here is the full code

const byte numSockets = 16;

const byte signalPins [numSockets] = {2, 3, 4, 5, 6, 7, 8, 9, A0, A1, A2, A3, A4, A5, A6, A7 };

const byte numConnections = 8;

const byte connections[numConnections] [2] = { {0,8}, {1,9}, {2,10}, {3,11}, {4,12}, {5,13}, {6,14}, {7,15} };
 
bool lastState[numConnections] = { false, false, false, false, false, false, false, false};


enum PuzzleState {Initialising, Running, Solved};
PuzzleState puzzleState = Initialising;

void Setup () {
pinMode(12, OUTPUT);
  for (int i=0; i<numSockets; i++) {
    pinMode(signalPins[i], INPUT_PULLUP);
  }
}

void loop() {
  bool AllWiresCorrect = true;
  bool stateChanged = false;

  for (int i=0; i<numConnections; i++) {
      byte pin1 = signalPins[connections[i][0]];
      byte pin2 = signalPins[connections[i][1]];

    bool currentState = isConnected(pin1, pin2);

  if (currentState != lastState[i]) {
   stateChanged = true;
   lastState[i] = currentState;
  }
if(currentState == false) {
  AllWiresCorrect = false;
}
  
  }

 if(AllWiresCorrect && puzzleState == Running) {
  onSolve();
 }
 else if (!AllWirescorrect && puzzleState == Solved) {
  onUnsolve();
 }


void onsolve() {
 digitalWrite(12,HIGH);
}

void onUnsolve() {
  digitalWrite(12,LOW);
}

bool isConnected(byte OutputPin, byte InputPin) {
  pinMode(OutputPin, OUTPUT);
  pinMode(InputPin, INPUT_PULLUP);

  digitalWrite (OutputPin, LOW);

  bool isConnected = !digitalRead(InputPin);

  pinMode(OutputPin, INPUT_PULLUP);
  return isconnected;
}
}

There are many errors in your code:

Misplaced closing brace. A very helpful troubleshooting tool is the Auto Format feature (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor). If you do an Auto Format and then compare the resulting indentation to your intended program structure, it will quickly point you to where there is a missing or extra brace.

Another useful feature of the Arduino IDE/Arduino Web Editor is that when you place the cursor next to one bracket, it puts a box around the matching bracket. In the Arduino IDE, if the cursor is next to the closing bracket and the opening bracket is off the screen then it will show the opening bracket line in a tool tip after a short delay.


Incorrect case used in references to variables and functions. For examples, onSolve() vs onsolve(), Setup() vs setup(). The Arduino programming language is case-sensitive. You need to always use the exact same case.


Ironically, out of the many errors, the one I don’t get is the “macro “isConnected” passed 2 arguments, but just takes 0” you claim.

Please do this:

  • When you encounter an error, you’ll see a button on the right side of the orange bar “Copy error messages” in the Arduino IDE (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button…
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum’s code tags markup to your reply.
  • Press “Ctrl + V”. This will paste the error between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.

If the text exceeds the forum’s 9000 character limit, save it to a .txt file and post it as an attachment. If you click the “Reply” button here, you will see an “Attachments and other settings” link that will allow you to make the attachment.

after doing what you mentioned, I am now getting this:

Arduino: 1.8.12 (Windows Store 1.8.33.0) (Windows 10), Board: "Arduino Nano, ATmega328P"

C:\Users\puzzl\OneDrive\Documents\Arduino\Blink\Patch_Cable_Game\Patch_Cable_Game.ino: In function 'void loop()':

Patch_Cable_Game:31:25: error: 'isConnected' was not declared in this scope

     bool currentstate = isConnected(Pin1, Pin2);

                         ^~~~~~~~~~~

Patch_Cable_Game:34:22: error: 'currentState' was not declared in this scope

       lastState[i] = currentState;

                      ^~~~~~~~~~~~

C:\Users\puzzl\OneDrive\Documents\Arduino\Blink\Patch_Cable_Game\Patch_Cable_Game.ino:34:22: note: suggested alternative: 'currentstate'

       lastState[i] = currentState;

                      ^~~~~~~~~~~~

                      currentstate

Patch_Cable_Game:43:5: error: 'onSolve' was not declared in this scope

     onSolve();

     ^~~~~~~

C:\Users\puzzl\OneDrive\Documents\Arduino\Blink\Patch_Cable_Game\Patch_Cable_Game.ino:43:5: note: suggested alternative: 'Solved'

     onSolve();

     ^~~~~~~

     Solved

Patch_Cable_Game:45:13: error: 'AllWirescorrect' was not declared in this scope

   else if (!AllWirescorrect && puzzleState == Solved) {

             ^~~~~~~~~~~~~~~

C:\Users\puzzl\OneDrive\Documents\Arduino\Blink\Patch_Cable_Game\Patch_Cable_Game.ino:45:13: note: suggested alternative: 'AllWiresCorrect'

   else if (!AllWirescorrect && puzzleState == Solved) {

             ^~~~~~~~~~~~~~~

             AllWiresCorrect

Patch_Cable_Game:46:5: error: 'onUnsolve' was not declared in this scope

     onUnsolve();

     ^~~~~~~~~

Patch_Cable_Game:50:18: error: a function-definition is not allowed here before '{' token

   void onsolve() {

                  ^

Patch_Cable_Game:54:20: error: a function-definition is not allowed here before '{' token

   void onUnsolve() {

                    ^

Patch_Cable_Game:58:51: error: a function-definition is not allowed here before '{' token

   bool isConnected(byte OutputPin, byte InputPin) {

                                                   ^

exit status 1
'isConnected' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

isconnected is not the same thing as isConnected. C++ is case sensitive.
same applies to onsolve() versus onSolve()
and also AllWiresCorrect and setup()

seems you are not using stateChanged in your loop, get rid of it

They are all the same, and I still get the same thing.

puzzledog1031:
They are all the same, and I still get the same thing.

I bet they are not or you did not fix the misplaced }

bug is line 42 and your red wire is not plugged in firmly… not 100% sure thought - just from what I can see
codeinfo.png
:slight_smile:

joke aside - post your code… and the compiler error… (as text )

const byte numSockets = 16;

const byte signalPins [numSockets] = {2, 3, 4, 5, 6, 7, 8, 9, A0, A1, A2, A3, A4, A5, A6, A7 };

const byte numConnections = 8;

const byte connections[numConnections] [2] = { {0, 8}, {1, 9}, {2, 10}, {3, 11}, {4, 12}, {5, 13}, {6, 14}, {7, 15} };

bool lastState[numConnections] = { false, false, false, false, false, false, false, false};


enum PuzzleState {Initialising, Running, Solved};
PuzzleState puzzleState = Initialising;

void Setup () {
  pinMode(12, OUTPUT);
  for (int i = 0; i < numSockets; i++) {
    pinMode(signalPins[i], INPUT_PULLUP);
  }
}

void loop() {
  bool AllWiresCorrect = true;

  bool stateChanged = false;

  for (int i = 0; i < numConnections; i++) {
    byte pin1 = signalPins[connections[i][0]];
    byte pin2 = signalPins[connections[i][1]];

    bool currentState = isConnected(pin1, pin2);
    if (currentState != lastState[i]) {
      stateChanged = true;
      lastState[i] = currentState;
    }
    if (currentState == false) {
      AllWiresCorrect = false;
    }
  }

  if (AllWiresCorrect && puzzleState == Running) {
    onSolve();
  }
  else if (!AllWirescorrect && puzzleState == Solved) {
    onUnsolve();
  }




  bool isConnected(byte OutputPin, byte InputPin) {
    pinMode(OutputPin, OUTPUT);
    pinMode(InputPin, INPUT_PULLUP);

    digitalWrite (OutputPin, LOW);

    bool isConnected = !digitalRead(InputPin);

    pinMode(OutputPin, INPUT_PULLUP);
    return isConnected;
  }
    void onSolve() {
    digitalWrite(12, HIGH);
  }

  void onUnsolve() {
    digitalWrite(12, LOW);
  }
}

:o :o you did not fix what I mentioned in #3 nor the closing } for the loop in the right place…

what do you expect?

I have checked every bracket, they all have a pair, so I am not sure what you are referring to.

Sure but one } does not close at the right place (for your loop).

press ctrl-T and look at your functions, they are not left aligned.

and a couple capitalization issues still

puzzledog1031:
I have checked every bracket, they all have a pair,

That does not guarantee that they are in the right places.

You have

void loop() { ...
  void onsolve() { ... }
  void onUnsolve() { ... }
  bool isConnected(byte OutputPin, byte InputPin) { ... }
}

when you should have

void loop() { ... }
void onsolve() { ... }
void onUnsolve() { ... }
bool isConnected(byte OutputPin, byte InputPin) { ... }