错误:数字常量之前的预期unqualified-id。不知道这意味着什么

时间:2015-03-31 17:50:53

标签: c arduino

我在使用arduino时遇到了这个错误代码。该代码用于接收文本并以莫尔斯电码输出LED。它目前没有文本输入功能。谢谢!

    void setup() {
      // put your setup code here, to run once:

    }

    void a(){
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);        
     digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
      delay(3000);   
    }
    void b(){
      digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000); 
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000); 
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000); 
    }

    void c(){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);  
      digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);  
    }
    void d(){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000); 
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000); 
    }
    void e(){
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);  
    }
    void f (){
    digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);    
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);    
      digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);   
    }
    void g (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000); 
    }
    void h (){
    digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);     
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);     
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);     
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);     

    }
    void i (){
    digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);     
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);     
    }
    void j (){
    digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);     
      digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(3000);

    }
    void k (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);  
     digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(3000);

    }
    void l (){
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);  
      digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);  
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);  
    }
    void m (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(3000);
    }
    void n (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);  
    }
    void o (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(3000);
    }
    void p (){
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);        
      digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);  
    }
    void q (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000); 
        digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(3000);
    }
    void r (){
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);  
      digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);  
    }
    void s (){
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);  
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);  
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);  
    }
    void t (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
    }
    void u (){
    digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000); 
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000); 
      digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(3000);
    }
    void v (){
    digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000); 
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000); 
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000); 
      digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(3000);
    }
    void w (){
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);  
      digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(3000);
    }
    void x (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000); 
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(3000);  
    }
    void y (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
      digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(3000);
    }
    void z (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);   

    }
    void 1 (){
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000); 
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(3000); 
    }
    void 2 (){
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000); 
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(3000);

    }
    void 3 (){
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
      digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(3000);
    }
    void 4 (){
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
      digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(3000);
    }

void 5是5号所以当有人输入9时,它会闪烁莫尔斯5

void 5 (){
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);   
       digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);   
    }
    void 6 (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);  digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);  digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);  digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);  
    }
    void 7 (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);  digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);  digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);  
    }
    void 8 (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(1000);  
      digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);  

void 9是9,所以当有人输入9时,它会闪烁莫尔斯9

    }
    void 9 (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
     digitalWrite(13, HIGH);
      delay(1000);    
      digitalWrite(13, LOW);
      delay(3000);  
    }
    void 0 (){
    digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);digitalWrite(13, HIGH);
      delay(3000);  
      digitalWrite(13, LOW);
     delay(1000);
    }


    void loop() {
      // put your main code here, to run repeatedly:
     //put enter text code here:

    }

谢谢!

以下是所有错误:

MorseBusyWork.ino:29:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:30:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:31:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:32:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:33:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:34:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:35:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:36:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:37:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:38:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:391:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:413:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:436:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:458:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:480:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:502:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:520:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:539:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:559:6: error: expected unqualified-id before numeric constant
MorseBusyWork.ino:578:6: error: expected unqualified-id before numeric constant
Error compiling.

MorseBusyWork是文件的名称......

2 个答案:

答案 0 :(得分:1)

您不能拥有一个名为数字常量的函数,请更改您的函数'名称为one(); two(); three();或者更好的是创建一个函数,该函数需要int,这将是闪烁和使用循环的次数,而不是以指数方式复制粘贴您自己的代码。

答案 1 :(得分:0)

您应该在您的功能中使用至少1个字母:

void number1(){
    // ...
}