如何修复“赋值的左操作数需要 1 个值”?

How to fix "1 value required as left operand of assignment"?

我想建立一个项目,每次测量值低于 800 时计数器都会计数,如果测量值超过 800 则重置。我尝试了很多东西,但很多都没有用,有些是方式变得复杂。请帮助我...下面是我的原始代码,它不起作用。

const int sensor = A0;
int x;

void setup(){
x = 0;
}

void loop(){
int Val = analogRead(sensor);
if(Val =< 800){
x + 1;
}
else{
x = 0;
}
delay(250);
}

在您的 if 条件中,您没有设置变量的值。你只是在表达。

if(Val =< 800){
x + 1;
}

正确的代码是再次将新值赋给变量,而且你的关系运算符是错误的..应该是<=

if(Val <= 800){
x = x + 1;
}