正面和负面的变化没有声明,并且在之前的情况下使用相同的声明非常高兴

问题描述

我们正在创建一个基于几个输入打开/关闭百叶窗的 arduino 系统

  1. 只能关闭百叶窗的光电传感器,即无法打开百叶窗
  2. 一个按钮,用于切换百叶窗处于打开或关闭的任何状态。 我们用 pos 跟踪我们的 pos
#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 (将#修改为@)