Skip to content

Instantly share code, notes, and snippets.

@MSakamaki
Last active April 9, 2016 07:41
Show Gist options
  • Save MSakamaki/ff162b0cc85827761b5c to your computer and use it in GitHub Desktop.
Save MSakamaki/ff162b0cc85827761b5c to your computer and use it in GitHub Desktop.
CHIRIMEN MEMO

usbでの接続方法

ADBコマンドで繋げる

# 接続確認
adb devices

# 繋げる
adb shell

# gpio
cd /sys/class/gpio

接続後

# i2c2番ポート調べる
i2cdetect -yr 2

GPIO MEMO

direction

  • 入力/出力の切り替え
  • out/in/high/lowの4種類が設定が可能
  • valueファイルではデータの取得と設定を行います。valueの値は,0と1でそれぞれlowとhighを意味
概要
  • in
  • 読み込み
  • out
  • 書き込み

links

CHIRIMEN

その他

HC-SR501

人感センサー

SPEC

Bower Component

接続

  • CN1.1 GND -> GND
  • CN1.8 gpio197 -> OUTPUT
  • CN1.18 VCC_5V -> POWER

CODE

window.addEventListener('load', function (){

  navigator.requestGPIOAccess().then(
    function(gpioAccess) {
        console.log("GPIO ready!");
        return gpioAccess;
    }).then(gpio=>{
      var port = gpio.ports.get(197);
      return port.export("in").then(()=>{
        port.onchange = function(value) {
          console.log('port onchange: ', value);
        }
      });
  }).catch(error=>{
    console.log("Failed to get GPIO access catch: " + error.message);
  });

}, false);

HC-SRO4

超音波センサー

接続

  • CN1.1 -> GND
  • CN1.7 (196)-> Trig
  • CN1.8 (197)-> Echo
  • CN1.18 VCC_5V -> VCC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment