Closed simar88 closed 9 years ago
Your write
function is executing immediately because you have put (pin,false)
after it. You need to declare write
as its own callback function, then call gpio.write
from within that. See "Setup and write to a pin" in the readme.
Thanks @JamesBarwell for the fast reply! I followed your guidelines for "setup and write" before write the issue and the function write is declared before as function that works as callback passing to it the pin and the value to write. After some hours made of test, update and upgrade raspberry i found that the problem was a sleep module for node.js. This module stop the execution of the callback so this write (that came after changing direction of the pin) doesn't find the pin exported. I solved before using nested operations ad then using async module to make operations in series and it works. Thanks again! :) Using it
Hello,
May you put your solved code here please ?
Working code would be:
var gpio = require('rpi-gpio');
gpio.setup(pin,gpio.DIR_OUT,write.bind(this, pin,false))
I'm having the same issue on rPi 2 using
gpio.setup(17, gpio.DIR_OUT, function() {
gpio.write(17, true, function(err) {
if (err) throw err;
console.log('Written to pin');
});
});
Error: Pin has not been exported for write
Ignore me, wasn't following the useful pin guide
I'm trying to use this module on my new Raspberry Pi 2 and i have this error:
I'm trying top open a pin and then write to it using a a custom callback in this way.
I'm using: sudo command; node version: 0.12.1;