arduino-c++ - 正面和负面的变化没有声明,它在之前的情况下非常高兴,同样的声明
问题描述
我们正在创建一个基于几个输入的 arduino 系统打开/关闭百叶窗
- 光传感器只能关闭百叶窗,即无法打开百叶窗
- 一个按钮,用于切换百叶窗处于打开或关闭的任何状态。我们用 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;
}
}
解决方案
推荐阅读
- image - 如何将PNG格式的图像转换为GIF格式
- mapstruct - 使用 Mapstruct 实现 REST“字段”查询参数
- python - Pillow & numpy - 将颜色从 RGBA 替换为透明
- javascript - 汇总未应用 Babel 转换
- python - Peerjs call.on('stream') 在第一个用户连接时不运行
- python - 我无法正确地将我的 python 数据附加到 JSON 文件中
- excel - 将 Excel 数据导入 SAS 并将表格转换为矩阵形式
- c++ - Linux 能够从 C++ 中的用户模式程序以 root 身份启动进程
- mysql - 在测试主机设置上的 MySQL Workbench 上设置新连接时出现错误
- elasticsearch - 属性存在且不为空/空字符串