You are reading a single comment by @jeffmer and its replies.
Click here to read the full conversation.
-
Yes, some of those options might help, however, the code below proved the simplest most reliable driver.
function createEncoder(pinA,pinB){ pinMode(pinA,"input_pullup"); pinMode(pinB,"input_pullup"); var a0=pinA.read(), c0=pinB.read(), incr0 =0, second=false; var OBJ = {}; function handler () { var a = pinA.read(); var b = pinB.read(); if (a != a0) { // A changed a0 = a; if (b != c0) { c0 = b; var incr = (a == b)?-1:1; if (incr!=incr0 || !second) OBJ.emit("change",incr); incr0=incr; second = !second; } } } setWatch(handler,pinA,{repeat:true,edge:"both"}); return OBJ; }
Wow, that looks great!
I don't think so, no. Whenever I used it they were on separate busses.
Have you seen
setWatch
has adata
argument? I guess it might work just to use that with a debounce. I guess a falling edge when data=0 is one way, falling with data=1 is another?