我想做一个简单的Arduino代码,当光电池读数小于900时,它会将1添加到CurrentNumber并将其显示在4位7段显示器上。问题是,它不会停止添加一个即使它的阅读超过1000C++如果然后不会工作/停止
void loop() {
photocellReading = analogRead(photocellPin);
Serial.print("Analog reading = ");
Serial.println(photocellReading); // the raw analog reading
photocellReading = 1023 - photocellReading;
if(photocellReading << 10){
CurrentNumber = CurrentNumber + 1;
}
displayNumber(CurrentNumber);
}
'if(photocellReading << 10){'这条线对我很可疑。你将位向左移动10倍,实际上乘以2^10。这是打算? – Borgleader
我不明白你的描述。但我很确定你想要'<',而不是'<<'。 –
'photocellReading'的类型是什么? – dmckee