- Output PINs initialize
- Set output state
- Release port
Provide functionality for hw digital output.
var OutPort = require('outport');
Output PINs initialize
This class supports the access and configuration of a port of output pins of the general purpose IO driver (GPIO). The usage of all GPIO ports is restricted to the same interface where the GPIO driver was opened. When the module starts up, all GPIO pins are set to high-impedance state after initializing. Therefore, it is recommended to connect pull-up or pull-down resistors to all GPIO pins you want to use as output. This is necessary to keep these pins from floating or driving any external devices before all settings are done by the output port constructor and after release the output port again.
OutPort (pins, init_values);
Constructor creates one serial port from defined GPIOs and sets to initial values.
Array pins - array of PIN's identificators.
Array init_values - initial state for pins.
Example new OutPort(..)
var pins = ['GPIO7','GPIO8','GPIO6','GPIO5']; var values = [0,0,0,1]; var outp = new OutPort(pins,values);
Set output state
Sets the current value of an instance of a GPIO port of output pins.
function will set output value.
number value - new state of port.
//set pin 8, 7 as ON // GPIO8 | GPIO7 | GPIO6 | GPIO5 // ----------------------------- // 8 | 4 | 2 | 1 // ----------------------------- // ON | ON | OFF | OFF outp.setPort(12);
Releases an instance of a GPIO port of output pins. The pins of the port are closed as well and can be added to a new port.
function releases an instance of OutPort and close assigned GPIOs.