mirror of
https://github.com/kou029w/megabit.git
synced 2025-02-23 00:55:17 +00:00
628 B
628 B
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();