在 Arduino 中重新声明为不同类型的符号

Redeclared as different kind of symbol in Arduino

我目前正在做一个学校项目。我希望伺服根据所选硬币的数量移动。我不断收到错误消息“'void servoOne()' 重新声明为不同类型的符号”我知道有人问过这个问题,但我不确定如何解决这个问题。

这是我的代码。

#include <LiquidCrystal.h>
#include <Keypad.h>
#include <Servo.h>

Servo servoOne;

String sharp="";
int piso=0;
int lima=0;
int sampu=0;

String input="";
String remlast = "";

LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);//RS,EN,D4,D5,D6,D7


const byte Rows= 4; //number of rows on the keypad i.e. 4
const byte Cols= 3; //number of columns on the keypad i,e, 3

//we will definne the key map as on the key pad:

char keymap[Rows][Cols]={
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte rPins[Rows]= {3,4,5,6}; //Rows 0 to 3
byte cPins[Cols]= {7,8,9}; //Columns 0 to 2

Keypad kpd= Keypad(makeKeymap(keymap), rPins, cPins, Rows, Cols);

void setup() {
  // put your setup code here, to run once:
lcd.begin(20,4);
servoOne.attach(10);
}

void loop() {
    char key2 = kpd.getKey();


  if (key2 != NO_KEY)
     { 
       lcd.print(key2);

       if (sharp == "")
       {
          input+=key2;
          remlast = input;
          remlast.replace("*","");
            remlast.replace("#","");
            piso = remlast.toInt();
       }
       else if (sharp == "five")
       {
          input+=key2;
          remlast = input;
          remlast.replace("*","");
            remlast.replace("#","");
            lima = remlast.toInt();
       }
       else if (sharp == "ten")
       {
          input+=key2;
          remlast = input;
          remlast.replace("*","");
            remlast.replace("#","");
            sampu = remlast.toInt();
       }

      if(key2=='*' && sharp!=NULL)
      {
        lcd.rightToLeft();
        sharp="";
        piso=0;
        lima=0;
        sampu=0;
        input="";
        remlast="";
      }  

      if (sharp=="ten" && key2=='#')
      {
        sharp = "out";
        lcd.clear();
        lcd.print(piso);
        lcd.print(lima);
        lcd.print(sampu);
        servoOne();
      }

     else if (sharp=="five" && key2=='#')
       {
          lcd.clear();
          lcd.print("10-peso=");
          lcd.setCursor(0,1);
          lcd.print("(*)Erase  (#)Enter");
          lcd.setCursor(8,0);  
          sharp="ten";  
          input = 0;      
       }

     else if (key2=='#')
      {
        lcd.clear();
        lcd.print("5-peso=");
        lcd.setCursor(0,1);
        lcd.print("(*)Erase  (#)Enter");
        lcd.setCursor(7,0); 
        sharp="five";
        input = 0;

      }
      if (key2=='*')
      {
        lcd.clear();
        lcd.print("1-peso=");
        lcd.setCursor(0,1);
        lcd.print("(*)Erase  (#)Enter");
        lcd.setCursor(7,0); 
      }

      }
   }

//--------------------SERVO ONE--------------------//
void servoOne()
{
  servoOne.write(70);
  delay(10);
  while(piso>0)
  {
    int x = piso;
    while(x>0)
    {
      servoOne.write(170);
      delay(200);
      servoOne.write(40);
      delay(200);
      x--;
    }
  }
}

它发生在 Servo servoOne;void servoOne() 中的 servoOne 之间发生冲突。请用其他名称替换 void servoOne() 中的 servoOne。 (不要忘记用新函数名替换函数调用中的函数名)