1
0
Fork 0
mirror of https://github.com/kou029w/megabit.git synced 2025-01-30 21:58:04 +00:00
Connect real things with Node.js
Find a file
2020-02-16 13:58:08 +00:00
.github/workflows 不要なので削除 2020-02-10 23:57:31 +09:00
src refactor 2020-02-07 13:58:09 +09:00
.gitignore github-pages に移行 2020-02-10 23:43:45 +09:00
LICENSE init 2020-02-07 12:34:43 +09:00
package.json v1.0.0-alpha.2 2020-02-07 14:41:43 +09:00
README.md init 2020-02-07 12:34:43 +09:00
renovate.json Update renovate.json 2020-02-08 19:53:19 +09:00
tsconfig.base.json enable noFallthroughCasesInSwitch 2020-02-12 02:36:45 +09:00
tsconfig.cjs.json enable esModuleInterop, allowJs 2020-02-07 14:38:54 +09:00
tsconfig.esm.json enable esModuleInterop, allowJs 2020-02-07 14:38:54 +09:00
yarn.lock Update dependency node-web-i2c to v1.1.3 2020-02-16 13:58:08 +00:00

Megabit

Connect real things with Node.js

Usage

GPIO Example

const { gpio } = require("megabit");
const sleep = require("util").promisify(setTimeout);

async function blink() {
  for (;;) {
    await gpio(26).write(1);
    await sleep(1000);
    await gpio(26).write(0);
    await sleep(1000);
  }
}

blink();

I2C Example

const { adt7410 } = require("megabit");

async function measure() {
  const temperature = await adt7410().read();
  console.log(`Temperature: ${temperature} ℃`);
}

measure();

Documents

Megabit API Documentation