A Node.js library to control USB connected relays
Go to file
Dana Woodman 4a6720e525 0.0.4
2018-07-23 13:21:02 -07:00
examples First pass at the API 🦄 2018-07-23 12:50:02 -07:00
src First pass at the API 🦄 2018-07-23 12:50:02 -07:00
.eslintignore First pass at the API 🦄 2018-07-23 12:50:02 -07:00
.eslintrc.yml First pass at the API 🦄 2018-07-23 12:50:02 -07:00
.gitignore First pass at the API 🦄 2018-07-23 12:50:02 -07:00
.nvmrc Change package name 2018-07-23 13:11:27 -07:00
.prettierignore First pass at the API 🦄 2018-07-23 12:50:02 -07:00
.prettierrc First pass at the API 🦄 2018-07-23 12:50:02 -07:00
package-lock.json 0.0.4 2018-07-23 13:21:02 -07:00
package.json 0.0.4 2018-07-23 13:21:02 -07:00
README.md Change package name 2018-07-23 13:11:27 -07:00

easy-usb-relay

THIS IS CURRENTLY IN AN EXPERIMENTAL STATE: It does not yet support multiple boards or other manufacturers. Coming soon...

A Node.js library to control USB connected relays

Setup

npm install --save easy-usb-relay

Usage

const { Board } = require('easy-usb-relay')

const numRelays = 2
const relays = new Board(numRelays)

// Turn all relays off:
relays.allOff()

// Turn all relays on:
relays.allOn()

// Turn relay #1 on:
relays.on(1)

// Turn relay #1 off:
relays.off(1)

Please see examples directory for more examples on using easy-usb-relay

API

relays.allOff()

Turn all relays off.

relays.allOn()

Turn all relays on.

relays.on(index)

Turn relay with index on. Index starts at 1 and goes to the number of available relays. Throws an exception if the relay index is greater than the available number of relays.

relays.off(index)

Turn relay with index off. Index starts at 1 and goes to the number of available relays. Throws an exception if the relay index is greater than the available number of relays.

Contribute

Contributions welcome! Please submit a Pull Request and make sure to format your code with Prettier and write tests!

License

MIT

Credits

© Dana Woodman 2018