2019-10-18 21:16:23 +09:00
|
|
|
# node-web-gpio
|
2019-10-13 02:13:19 +09:00
|
|
|
|
|
|
|
GPIO access with Node.js
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```js
|
2019-10-18 21:16:23 +09:00
|
|
|
const { requestGPIOAccess } = require("node-web-gpio");
|
2019-10-15 20:38:53 +09:00
|
|
|
const { promisify } = require("util");
|
|
|
|
const sleep = promisify(setTimeout);
|
2019-10-13 02:13:19 +09:00
|
|
|
|
|
|
|
async function main() {
|
|
|
|
const gpioAccess = await requestGPIOAccess();
|
|
|
|
const port = gpioAccess.ports.get(26);
|
|
|
|
|
|
|
|
await port.export("out");
|
|
|
|
|
|
|
|
for (;;) {
|
2019-10-15 20:38:53 +09:00
|
|
|
await port.write(1);
|
|
|
|
await sleep(1000);
|
|
|
|
await port.write(0);
|
|
|
|
await sleep(1000);
|
2019-10-13 02:13:19 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
main();
|
|
|
|
```
|
|
|
|
|
|
|
|
## Document
|
|
|
|
|
2023-02-17 16:05:54 +09:00
|
|
|
- [TSDoc](http://chirimen.org/node-web-gpio/)
|
|
|
|
|
|
|
|
## Reference
|
|
|
|
|
|
|
|
- [Web GPIO API for W3C Draft](http://browserobo.github.io/WebGPIO)
|