JamesBarwell / rpi-gpio.js

Control Raspberry Pi GPIO pins with node.js
MIT License
657 stars 116 forks source link

Only pin 31 seems to work as in input #110

Closed Tmp2k closed 3 years ago

Tmp2k commented 3 years ago

I have several pins connected to GND via push buttons and here's my code....

gpio.setup(13, gpio.DIR_IN, gpio.EDGE_BOTH, (err) => { this.error(err) }); //Right Top
gpio.setup(15, gpio.DIR_IN, gpio.EDGE_BOTH, (err) => { this.error(err) }); //Top Right
gpio.setup(16, gpio.DIR_IN, gpio.EDGE_BOTH, (err) => { this.error(err) }); //Left Bottom
gpio.setup(18, gpio.DIR_IN, gpio.EDGE_BOTH, (err) => { this.error(err) }); //Bottom Left
gpio.setup(22, gpio.DIR_IN, gpio.EDGE_BOTH, (err) => { this.error(err) }); //Left Top
gpio.setup(37, gpio.DIR_IN, gpio.EDGE_BOTH, (err) => { this.error(err) }); //Top Left
gpio.setup(36, gpio.DIR_IN, gpio.EDGE_BOTH, (err) => { this.error(err) }); //Right Bottom
gpio.setup(32, gpio.DIR_IN, gpio.EDGE_BOTH, (err) => { this.error(err) }); //Bottom Right
gpio.setup(31, gpio.DIR_IN, gpio.EDGE_BOTH, (err) => { this.error(err) }); //Home

gpio.on('change',  (channel, value) => {
    this.debug('Button change... CH:'+channel+' Val:'+value);
    this.setButton(channel, !value);
});

Only pin 31 works. All the buttons are connected in the same way. I've tried moving the setup for pin31 further up the code, in case the reason only that pin was working is because it's the last pin to be set up, but that changed nothing.

I've checked the wiring for continuity, all works as expected.

Any ideas?

Tmp2k commented 3 years ago

This was my mistake after all! Although I'm not sure how pin 31 was still working.