mirror of
https://github.com/chirimen-oh/node-web-gpio.git
synced 2025-01-18 08:05:07 +00:00
GPIO access with Node.js
bee6d5fe2d
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> |
||
---|---|---|
.github/workflows | ||
.husky | ||
docs | ||
.eslintrc.yml | ||
.gitignore | ||
.lintstagedrc.yaml | ||
index.ts | ||
LICENSE | ||
package.json | ||
README.md | ||
renovate.json | ||
tsconfig.json | ||
typedoc.json | ||
yarn.lock |
node-web-gpio
GPIO access with Node.js
Usage
const { requestGPIOAccess } = require("node-web-gpio");
const { promisify } = require("util");
const sleep = promisify(setTimeout);
async function main() {
const gpioAccess = await requestGPIOAccess();
const port = gpioAccess.ports.get(26);
await port.export("out");
for (;;) {
await port.write(1);
await sleep(1000);
await port.write(0);
await sleep(1000);
}
}
main();