Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danawoodman/easy-usb-relay
A Node.js library to control USB connected relays
https://github.com/danawoodman/easy-usb-relay
control electronics hardware hid iot relay sainsmart usb
Last synced: 29 days ago
JSON representation
A Node.js library to control USB connected relays
- Host: GitHub
- URL: https://github.com/danawoodman/easy-usb-relay
- Owner: danawoodman
- Created: 2018-07-23T19:50:14.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-06T01:11:30.000Z (about 6 years ago)
- Last Synced: 2024-09-05T02:39:30.866Z (3 months ago)
- Topics: control, electronics, hardware, hid, iot, relay, sainsmart, usb
- Language: JavaScript
- Homepage:
- Size: 145 KB
- Stars: 3
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```bash
npm install --save easy-usb-relay
```## Usage
```js
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](/examples) 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](http://danawoodman.com) 2018