1
0
Fork 0
mirror of https://github.com/kou029w/megabit.git synced 2025-01-29 13:28:03 +00:00
Connect real things with Node.js
Find a file
2023-08-25 10:37:23 +09:00
src bump version 2021-07-25 00:03:48 +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 use jsdoc.io 2022-08-01 17:05:40 +09:00
README.md 開発終了 2023-08-25 10:37:23 +09:00
renovate.json format 2021-07-24 23:28:23 +09:00
tsconfig.base.json bump version 2021-07-25 00:03:48 +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 use jsdoc.io 2022-08-01 17:05:40 +09:00

このプロジェクトは現在メンテナンスされていません。もしフィードバックあればMastodon/ActivityPubにてお寄せください。

Megabit

jsDocs.io

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 { sht30 } = require("megabit");

async function measure() {
  const { humidity, temperature } = await sht30().read();
  console.log(`Humidity: ${humidity.toFixed(2)} %`);
  console.log(`Temperature: ${temperature.toFixed(2)} ℃`);
}

measure();

Documents

Megabit API Reference

Devices

Device Description API
ADS1015 12-bit Precision Analog to Digital Converter ads1015
ADT7410 High Accuracy Digital Temperature Sensor adt7410
ADXL345 3-axis Accelerometer adxl345
GP2Y0E03 4-50 cm Distance Sensor gp2y0e03
MPR121 Proximity Capacitive Touch Sensor Controller mpr121
PAJ7620 Gesture Recognition Sensor paj7620
PCA9685 16-Channel 12-Bit PWM/Servo Driver pca9685
S11059 Color Sensor s11059
SHT30 Humidity and Temperature Sensor sht30
SSD1306 128x64 Dot Matrix OLED ssd1306
SSD1308 128x64 Dot Matrix OLED ssd1308
TSL2561 Ambient Light Sensor tsl2561
VEML6070 UV(A) Light Sensor veml6070
VL53L0X Time of Flight Distance Sensor vl53l0x