node.js - rpi-gpio pin always high/low -


we using rpi-gpio , node.js read/write raspberry version 1 pins.

we have led connected gnd (pin 3) , gpio4 (pin 7).

using write works perfectly:

gpio.setup(7, gpio.dir_out, write);  function write() {     gpio.write(7, true, function(err) {         if (err) throw err;         console.log('written pin');     }); } 

although using read function

gpio.setup(7, gpio.dir_in, readinput);  function readinput() {     gpio.read(7, function(err, value) {         console.log('the value ' + value);     }); } 

leads following behavior:

1) led turned off 2) status of gpio pin true

setting the port "true" led light makes no difference. when reading pin led off , pin true.

the same inverse pin 11, 12 - led off , pin false.

using listener value changes on specific pin works ... although want read pin-value on demand!

for writing, set gpio pin output (which good). when try 'read' set gpio pin input changes mode of pin. try remove:

gpio.setup(7, gpio.dir_in, readinput); 

from raspberry pi forum:

five of 17 available gpio lines pulled high default (the rest pulled low). numbers gpio0/2, gpio1/3, gpio4, gpio7 , gpio8.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -