gpt4 book ai didi

c - Arduino : "error: expected unqualified-id before ' {' token"

转载 作者:行者123 更新时间:2023-11-30 19:36:29 26 4
gpt4 key购买 nike

当我尝试编译此代码时,我在标题中收到错误消息。我对此很陌生,不确定是否有什么事情完全超出了我的理解范围。这段代码只是为了测试我试图用 arduino 实现自动驾驶的遥控汽车上的接线。我之前曾在这里作为问题看到过此错误消息,但我找不到将那里的解决方案应用到我的代码的方法。我尝试查看所有括号并确保它们彼此配对(例如 {},而不是 {{ 或 }} 或 }{)。我希望能够在感恩节假期之前解决这个问题,因此非常感谢任何帮助。

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 ()
{
...
}

关于c - Arduino : "error: expected unqualified-id before ' {' token",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40707343/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com