mirror of
https://github.com/chirimen-oh/node-web-gpio.git
synced 2025-01-18 08:05:07 +00:00
8476a25184
README ドキュメント追加 --------- Co-authored-by: akihiko kigure <akihiko.kigure@lifewood-m1.local>
35 lines
606 B
Markdown
35 lines
606 B
Markdown
# node-web-gpio
|
|
|
|
GPIO access with Node.js
|
|
|
|
## Usage
|
|
|
|
```js
|
|
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
|
|
|
|
- [TSDoc](http://chirimen.org/node-web-gpio/)
|
|
|
|
## Reference
|
|
|
|
- [Web GPIO API for W3C Draft](http://browserobo.github.io/WebGPIO)
|