mirror of
https://github.com/chirimen-oh/node-web-gpio.git
synced 2025-01-19 00:18:02 +00:00
docs: fix undefined variable
This commit is contained in:
parent
5842775133
commit
3c05ccf9ce
1 changed files with 6 additions and 2 deletions
|
@ -6,6 +6,8 @@ GPIO access with Node.js
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { requestGPIOAccess } = require("@notweb/gpio");
|
const { requestGPIOAccess } = require("@notweb/gpio");
|
||||||
|
const { promisify } = require("util");
|
||||||
|
const sleep = promisify(setTimeout);
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const gpioAccess = await requestGPIOAccess();
|
const gpioAccess = await requestGPIOAccess();
|
||||||
|
@ -14,8 +16,10 @@ async function main() {
|
||||||
await port.export("out");
|
await port.export("out");
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
await port.write(value);
|
await port.write(1);
|
||||||
await new Promise(resolve => setTimeout(resolve, 1e3));
|
await sleep(1000);
|
||||||
|
await port.write(0);
|
||||||
|
await sleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue