GPIO access with Node.js
Find a file
2020-02-06 23:46:43 +09:00
.gitignore create @notweb/gpio 2019-10-13 02:13:19 +09:00
index.d.ts yarn build 2019-11-08 16:29:10 +09:00
index.js yarn build 2019-10-18 21:44:44 +09:00
index.ts Compliant with specification in Web GPIO API 2019-10-18 21:43:32 +09:00
LICENSE create @notweb/gpio 2019-10-13 02:13:19 +09:00
package.json update repository url 2020-02-06 23:46:43 +09:00
README.md rename @notweb/gpio to node-web-gpio 2019-10-18 21:43:27 +09:00
tsconfig.json create @notweb/gpio 2019-10-13 02:13:19 +09:00
yarn.lock update to typescript 3.7 2019-11-08 16:26:29 +09:00

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();

Document

Web GPIO API