试图让光扰动者通过电线命令对EV3进行模拟读数
这是代码的一部分,我们在
//turns on the i2c commands
#include <Wire.h>
//creates a variable called SLAVE_ADDRESS and permanently sets the value to 0x04 (register #4)
#define SLAVE_ADDRESS 0x04
#define IR1 A0
#define IR2 A1
#define prnt
#define measure
#define measurea
void setup()
{
Serial.begin(9600);
//sets the address of the Arduino
Wire.begin(SLAVE_ADDRESS);
//the .onRequest command will run a function when it gets a request from the EV3.
//In this case, it will run the requestEvent function, which is defined later in the sketch.
Wire.onRequest(requestEvent);
}
int measureMap = 0;
void loop() {
int measure = analogRead(A0);
int measurea = analogRead(A1);
measureMap = map(measure, 0, 1023, 0, 63);
Serial.print(mapMeasure);
Serial.print (" ");
Serail.println(measure);
Serail.println(measure1);
}
拥有变量measurea
的位置上遇到错误,我们会遇到一个错误,说明
measurea
exit status 1
expected unqualified-id before '=' token
如何修复错误?
Here is the part of the code we are getting the error on
//turns on the i2c commands
#include <Wire.h>
//creates a variable called SLAVE_ADDRESS and permanently sets the value to 0x04 (register #4)
#define SLAVE_ADDRESS 0x04
#define IR1 A0
#define IR2 A1
#define prnt
#define measure
#define measurea
void setup()
{
Serial.begin(9600);
//sets the address of the Arduino
Wire.begin(SLAVE_ADDRESS);
//the .onRequest command will run a function when it gets a request from the EV3.
//In this case, it will run the requestEvent function, which is defined later in the sketch.
Wire.onRequest(requestEvent);
}
int measureMap = 0;
void loop() {
int measure = analogRead(A0);
int measurea = analogRead(A1);
measureMap = map(measure, 0, 1023, 0, 63);
Serial.print(mapMeasure);
Serial.print (" ");
Serail.println(measure);
Serail.println(measure1);
}
Where we have the variable measurea
we get an error saying
measurea
exit status 1
expected unqualified-id before '=' token
How to fix the error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题在于您已经声明
suberuea
和measure
为define
宏。您不能用相同名称制作变量。
尝试以下操作:
The problem is that you already declared
measurea
andmeasure
as adefine
macro.You can't make a variable with the same name.
try this: