huoshu
获得 0 次赞
帮助过0人
旋转编码器里面的结构是一个开了很多条透光通道的码盘,而两个光电传感器安装的位置是相差一定的角度,这样当码盘转动的时候两个光电传感器通过和关闭就形成了一定的顺序,这就是AB正交的原理。但是AB正交编码器输出的信号为什么是CLK和DT,并且arduino端的程序如下 int val; int encoder0PinA = 3; int encoder0PinB = 4; int encoder0Pos = 0; int encoder0PinALast = LOW; int n = LOW; void setup() { pinMode (encoder0PinAINPUT); pinMode (encoder0PinBINPUT); } void loop() { n = digitalRead(encoder0PinA); if ((encoder0PinALast == LOW) && (n == HIGH)) { if (digitalRead(encoder0PinB) == LOW) { encoder0Pos--; } else { encoder0Pos++;这个程序从LOOP开始无法理解