Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的树莓派上运行了节点,当你按下按钮时,rpio.read(22)将返回 0 而不是 1。
rpio.read(22)
我想检测何时发生这种情况,并从中触发一个功能。我怎样才能做到这一点?
现在最好的方法可能是不断循环,直到值发生rpio.read(22)变化。它不是很优雅,但你可以这样做:
function buttonCheck(){ if (rpio.read(22) == 0) { // code here } else { process.nextTick(buttonCheck); } }