Arduino: "error: expected unqualified-id before '{' token"
Arduino: "error: expected unqualified-id before '{' token"
当我尝试编译这段代码时,我得到了标题中的错误消息。我对此很陌生,不确定是否有什么事情完全超出了我的理解范围。这段代码只是为了测试我试图用 arduino 自动驾驶的 RC 汽车上的接线。我以前在这里作为问题看到过此错误消息,但我找不到将那里的解决方案应用到我的代码的方法。我已经尝试查看所有括号并确保它们彼此配对(例如 {},而不是 {{ 或 }} 或 }{)。我希望能够在感恩节假期前解决此问题,因此非常感谢您的帮助。
int driveneg = 9;
int drivepos = 5; /*this shows all my variables*/
int steeringneg = 6;
int steeringpos = 3;
byte speed =255;
void setup ();
{
pinMode (steeringneg, OUTPUT);
pinMode (steeringpos, OUTPUT); /*setting the motors to output*/
pinMode (driveneg, OUTPUT);
pinMode (drivepos, OUTPUT);
}
void loop ();
{
forward();
delay (2000);
backward();
delay (2000);
}
void backward();
{
analogWrite (9,0);
analogWrite (5, speed);/*defines forward and backward functions*/
analogWrite (6, 0);
analogWrite (3, speed);
}
void forward();
{
analogWrite (9, speed);
analogWrite (5, 0);
analogWrite (6, speed);
analogWrite (3, 0);
}
去掉函数括号后的分号(;
),像这样:
void setup ()
{
...
}
当我尝试编译这段代码时,我得到了标题中的错误消息。我对此很陌生,不确定是否有什么事情完全超出了我的理解范围。这段代码只是为了测试我试图用 arduino 自动驾驶的 RC 汽车上的接线。我以前在这里作为问题看到过此错误消息,但我找不到将那里的解决方案应用到我的代码的方法。我已经尝试查看所有括号并确保它们彼此配对(例如 {},而不是 {{ 或 }} 或 }{)。我希望能够在感恩节假期前解决此问题,因此非常感谢您的帮助。
int driveneg = 9;
int drivepos = 5; /*this shows all my variables*/
int steeringneg = 6;
int steeringpos = 3;
byte speed =255;
void setup ();
{
pinMode (steeringneg, OUTPUT);
pinMode (steeringpos, OUTPUT); /*setting the motors to output*/
pinMode (driveneg, OUTPUT);
pinMode (drivepos, OUTPUT);
}
void loop ();
{
forward();
delay (2000);
backward();
delay (2000);
}
void backward();
{
analogWrite (9,0);
analogWrite (5, speed);/*defines forward and backward functions*/
analogWrite (6, 0);
analogWrite (3, speed);
}
void forward();
{
analogWrite (9, speed);
analogWrite (5, 0);
analogWrite (6, speed);
analogWrite (3, 0);
}
去掉函数括号后的分号(;
),像这样:
void setup ()
{
...
}