我目前有一个带有wifi屏蔽的arduino,连接到一个PIR探测器和一个网站。这应该控制一个锁。我已经完成了所有这些工作,但有一部分我想改进。我可以改变PIR探测器吗?如果过去有移动,例如5秒钟,它将允许它打开(如果字母也是正确的)?它现在的做法是,它必须不断移动,否则它会在几秒钟内锁定。请注意,我是新来的Arduino编码,这样下去容易对我试图让我的一块arduino代码基于时间
while (client.available()){
int sensorValue2 = analogRead(A1); //Input from PIR-detector
Serial.println(sensorValue2);
char c = client.read();
Serial.write(c);
if ((sensorValue2 > 0.0) && (c == 'L')) { //If the input from the detector is over 0.0, and the text which is received from the website is 'L', the lock will open
digitalWrite(5, LOW);
}
else{
digitalWrite(5, HIGH);
}
}
看看“没有延迟的瞬间”的例子,你需要的东西就像它 – dandavis