no matching function for call to 'Servo::writeMicroseconds(__complex__ int)'

Hi, here is my code to operate some robot that help people walk.

#include <Servo.h>

int joystick_x = A0;
int joystick_y = A1;
int joystick_z = A2;
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo motorl;
Servo motorr;
Servo motorhl;
Servo motorhr;


void setup() {
  pinMode(joystick_z.INPUT_PULLUP);
  Serial.begin(9600);
  servo1.writeMicroseconds(2200);
  servo2.writeMicroseconds(2200);
  servo3.writeMicroseconds(2200);
  servo4.writeMicroseconds(2200);
  motorr.writeMicroseconds(840);
  motorl.writeMicroseconds(840);
  motorhr.writeMicroseconds(840);
  motorhr.writeMicroseconds(840);
  int alh = servo1.readMicroseconds();
  int all = servo2.readMicroseconds();
  int arh = servo3.readMicroseconds();
  int arl = servo4.readMicroseconds();
  int lr = motorr.readMicroseconds();
  int ll = motorl.readMicroseconds();
  int i;

  int x = analogRead(joystick_x);
  int y = analogRead(joystick_y);
  int z = digitalRead(joystick_z);
  Serial.print("control actuator by moving a joystick");
  while (z = 0) {
    if (y > 0) {
      for (delay(0.3); y > 0; alh = alh + 10); {
        servo1.writeMicroseconds(alh); servo2.writeMicroseconds(alh); delay(0.002);
      }
    }
    else {
      for (delay(0.3); y < 0; alh = alh - 10); {
        servo1.writeMicroseconds(alh); servo2.writeMicroseconds(alh); delay(0.002);
      }
    }
  }

  Serial.print("complete!");
  Serial.print("move your joystick to control");
  while (z = 0) {
    if (y > 0) {
      for (delay(0.3); y > 0; alh = alh + 10); {
        servo3.writeMicroseconds(alh); servo4.writeMicroseconds(alh); delay(0.002);
      }
    }
    else {
      for (delay(0.3); y < 0; alh = alh - 10); {
        servo3.writeMicroseconds(alh); servo4.writeMicroseconds(alh); delay(0.002);
      }
    }
  }
  Serial.print("yeah");
}


void loop()
{
  int x = analogRead(joystick_x);
  int y = analogRead(joystick_y);
  int z = digitalRead(joystick_z);
  int i;
  
  if (y > 0) {
    while (z = 0) {
      motorr.writeMicroseconds(0);
      motorhr.writeMicroseconds(0);
      delay(0.05);
      int i; motorr.writeMicroseconds(100);
      for (i = 0; i = 2100; i = i + 10);{
        motorhr.writeMicroseconds(i); motorr.writeMicroseconds(i + 100); motorhl.writeMicroseconds(840 - 2 * i / 5);
      }
      motorhl.writeMicroseconds(2200);

      motorl.writeMicroseconds(0);
      motorhl.writeMicroseconds(0);
      delay(0.05);
      motorl.writeMicroseconds(100);
      for (i = 0; i = 2100; i = i + 10); {
        motorhl.writeMicroseconds(i); motorl.writeMicroseconds(i + 100); motorhr.writeMicroseconds(840 - 2 * i / 5);
      }
      motorhl.writeMicroseconds(2200);
    }
  }
  else {
    while (z = 0 && y < 0) {
      motorr.writeMicroseconds(100);
      for (i = 0; i = 420; i = i + 2); {
        motorr.writeMicroseconds(2i); motorhr.writeMicroseconds(2100 + i); motorhl.writeMicroseconds(2100 - i);
      }
      motorhr.writeMicroseconds(2200); motorhl.writeMicroseconds(2200);
      motorl.writeMicroseconds(100);
      for (i = 0; i = 420; i = i + 2); {
        motorl.writeMicroseconds(2i); motorhl.writeMicroseconds(2100 + i); motorhr.writeMicroseconds(2100 - i);
      }
      motorhl.writeMicroseconds(2200); motorhr.writeMicroseconds(2200);
    }
  }
}

and here is my error

In file included from C:\Users\준우\AppData\Local\Temp\arduino_build_548293\sketch\sketch_jul21a4.ino.cpp:1:0:

C:\Users\以??슦\Desktop\R&E\sketch_jul21a4\sketch_jul21a4.ino: In function 'void setup()':

C:\Users\준우\Documents\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\cores\arduino/Arduino.h:45:22: error: expected unqualified-id before numeric constant

 #define INPUT_PULLUP 0x2

                      ^

C:\Users\以??슦\Desktop\R&E\sketch_jul21a4\sketch_jul21a4.ino:19:22: note: in expansion of macro 'INPUT_PULLUP'

C:\Users\以??슦\Desktop\R&E\sketch_jul21a4\sketch_jul21a4.ino: In function 'void loop()':

sketch_jul21a4:109: error: no matching function for call to 'Servo::writeMicroseconds(__complex__ int)'

C:\Users\以??슦\Desktop\R&E\sketch_jul21a4\sketch_jul21a4.ino:109:36: note: candidate is:

In file included from C:\Users\以??슦\Desktop\R&E\sketch_jul21a4\sketch_jul21a4.ino:3:0:

C:\Users\준우\Documents\arduino-1.8.5-windows\arduino-1.8.5\libraries\Servo\src/Servo.h:108:8: note: void Servo::writeMicroseconds(int)

   void writeMicroseconds(int value); // Write pulse width in microseconds 

        ^

C:\Users\준우\Documents\arduino-1.8.5-windows\arduino-1.8.5\libraries\Servo\src/Servo.h:108:8: note:   no known conversion for argument 1 from '__complex__ int' to 'int'

sketch_jul21a4:115: error: no matching function for call to 'Servo::writeMicroseconds(__complex__ int)'

C:\Users\以??슦\Desktop\R&E\sketch_jul21a4\sketch_jul21a4.ino:115:36: note: candidate is:

In file included from C:\Users\以??슦\Desktop\R&E\sketch_jul21a4\sketch_jul21a4.ino:3:0:

C:\Users\준우\Documents\arduino-1.8.5-windows\arduino-1.8.5\libraries\Servo\src/Servo.h:108:8: note: void Servo::writeMicroseconds(int)

   void writeMicroseconds(int value); // Write pulse width in microseconds

What am i doing wrong? What should i do? :sob: :sob:

As a start, pinMode(joystick_z.INPUT_PULLUP);
change the dot to a comma.

The other errors are related to the library and often suggest a spelling mistake.

while (z = 0) {

Oopsh

for (delay(0.3);

and another.

for (i = 0; i = 2100;

and another.

    while (z = 0 && y < 0) { etc.

You need to refine your approach to writing code - write a small amount, then test it.
You should never have got to the stage where you've got so much unworkable code

       motorl.writeMicroseconds(2i);

That is not how you multiply a variable by a number in C++, if that is what you intended to do

oru1123:
What am i doing wrong?

  • You are using '=' in place of '==' in boolean expressions.
  • You are declaring variables you never use.
  • You are calling delay() with a non-integer number of milliseconds (use delayMicroseconds() for smaller delays).
  • You put more than one statement on a line, making the sketch harder to read.
  • You put delay calls as the initialization expression of a 'for' loop.
  • You have almost no comments to say WHY your sketch is doing something.
  • You have 'for' loops where the control variable never changes.
  • You are using values over 2000 in servo.writeMicroseconds().
  • You used a '.' where you should have used a ','.
  • You used "2i" where you probably meant "2*i".

There may be other things that you did wrong.

oru1123:
What should i do? :sob: :sob:

Fix all of the things you have done wrong. In Preferences, set the compiler warning level to "ALL". Then try to compile your sketch again. Repeat fixing things until it compiles without errors or warnings. If you get an error or warning you can't figure out, post a reply here with your new sketch and a description of what error you can't figure out.