如何解决正面和负面的变化没有声明,并且在之前的情况下使用相同的声明非常高兴
我们正在创建一个基于几个输入打开/关闭百叶窗的 arduino 系统
#include <Stepper.h>
int buttonstate = 0;
void setup() {
Stepper myStepper(stepsPerRevolution,8,10,9,11);
Serial.begin(9600);
//Speed is variable up 10,11 starts to make issues
myStepper.setSpeed(10);
const int stepsPerRevolution = 2048;
const int button = 5;
int pos = 2;
int prevpos = 2;
int idrread = 0;
pinMode(button,INPUT);
}
void loop() {
buttonstate = digitalRead(button);
idrread = analogRead(A7);
switch (buttonstate)
// sure if the && statements would work
case (buttonstate == HIGH && pos == 2):
myStepper.step(stepsPerRevolution);//change these lines to the correct steps for correct roation,or leave them for demonstaration
pos = 1;
case (buttonstate == HIGH && pos ==1):
这是它在 -stepsPerRevolution 上绊倒的地方
myStepper.step(-stepsPerRevolution);
pos =2;
// if the blinds are open and the sensor reads light on,close the blinds
if (pos ==2 && idrread < 940/*can change as well as <,>*/){
myStepper.step(stepsPerRevolution);
pos = 1;
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。