2017-08-31 13 views
1

現在、私は学校プロジェクトに取り組んでいます。私は選択されたコインの数に従ってサーボを動かしたい。私はエラー "'voidサーボオン()'を別の種類のシンボルとして再宣言し続ける"私はこれが尋ねられていることを知っているが、私はこれを修正する方法がわからない。Arduinoで別の種類のシンボルとして再宣言しました

ここに私のコードです。

#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--; 
    } 
    } 
} 
+3

「servoOne」と呼ばれる関数とグローバル変数があります。それらの名前を変更してください。 – WolfLink

答えて

2

Servo servoOne;servoOnevoid servoOne()間の衝突のようにそれが起こります。 void servoOne()servoOneを別の名前に置き換えてください。 (関数名の関数名を新しい関数名で置き換えることを忘れないでください)

関連する問題