所有关于电路

试图用串行监视器构建计步器作为显示

hbasile91.

螺纹启动器

hbasile91.

加入2020年12月6日
103.
使用Arduino Uno,获取错误消息,似乎是一个语法错误...... ???

还有几种其他草稿,在一个我能够阅读我的串行监视器“1”,仍然加速度计,“11”用于移动加速度计

在另一个中,我能够阅读仍然加速计,而“1”用于移动加速度计

此选草稿不会成功编译

我希望它在串行监视器上以0开始,每次加速度计都会在3轴中的任何一个上移动

帮助受到赞赏,对我很容易,我是一个初学者

这是我的代码 - 错误消息:预期'x'之前')'

C:
const int xpin = a0;Const int Ypin = A1;Const int Zpin = A2;int步骤= 0;int x = 1;void setup(){pinmode(xpin,输入);Pinmode(Ypin,输入);Pinmode(Zpin,输入);Serial.Begin(9600);void循环(){int a = angogread(xpin); delay (500); int b = analogRead (ypin); delay (500); int c = analogRead (zpin); delay (500); if (a < 678) { Serial.print (Steps ++x); } if (b <= 464 ) { Serial.print (Steps ++x); } if (c <=4 ) { Serial.print (Steps ++x); } if (a >= 680) { Serial.print (Steps ++x); } if (b >= 674) { Serial.print (Steps ++x); } if (c > 6) { Serial.print (Steps ++x); } }
主持人注意:使用的代码标签
上次编辑:
djsfantasi.

djsfantasi.

加入2010年4月11日
7,598
什么是用于的可变步骤?您定义它,永远不会改变它。

我有一个想法你可能想要在显示屏上显示单词步骤......是这种情况吗?然后,您不需要变量。只是通过字符常量引用它。

serial.println(“步骤”,++ x);
hbasile91.

螺纹启动器

hbasile91.

加入2020年12月6日
103.
感谢大家。我现在已经努力工作,现在使用这段代码

const int xpin = a0;
Const int Ypin = A1;
Const int Zpin = A2;
int步骤= 0;

void setup()
{
Pinmode(Xpin,输入);
Pinmode(Ypin,输入);
Pinmode(Zpin,输入);

Serial.Begin(9600);
}


void循环()
{
int x = analogread(xpin);
延迟(500);
int y = analogread(ypin);
延迟(500);
int z = analogread(Zpin);
延迟(500);

if(z <= 4)
{
serial.println(步骤++);
}
}
最佳