I am trying to control the shift register in nodejs using the enotionz / gpiO library ..
here: https://github.com/EnotionZ/GpiO
I can not get it to work for some reason.
The expected result for the shift register is 74hc595n for a 0 on loop output. The pins identified to control the shift register are set as variables in both sets of code.
The python code I developed works fine:
I believe that it cyclically passes through each zone and depending on what you set in setShiftRegister(<arr key>) , in which "zone" it needs to be included.
I also included a working example in python.
here is my js code:
var gpio = require('gpio'); var sr_data, sr_clock, sr_latch, sr_oe, stations = [0,0,0,0,0,0,0,0]; console.log('hello there'); //shift register DS data (GPIO27, PIN 13) sr_data = gpio.export(13, { direction: 'out', ready:function(){ cb('exported sr_data'); } }); //shift register SH_CP clock (GPIO4, PIN 7) sr_clock = gpio.export(7, { direction: 'out', ready:function(){ cb('exported sr_clock'); } }); //shift register ST_CP latch pin (GPIO22, PIN 15) sr_latch = gpio.export(15, { direction: 'out', ready:function(){ cb('exported sr_latch'); } }); //shift register OE output enable, goes to ground (GPIO17, PIN 11) sr_oe = gpio.export(11, { direction: 'out', ready:function(){ cb('exported sr_oe'); sr_oe.set(0); } }); setTimeout(function(){ console.log('Enabling SR Pin: ', 0); //set the latch pin low for as long as we are clocking through the shift register console.log('-----------------------------------'); //shift pins up using bitwise, i = pin
This is python code that works
import RPi.GPIO as GPIO import atexit