LoginSignup
0
0

More than 5 years have passed since last update.

raspberry pi で、MCP23017 の入力ポートを使う Node.js 版

Last updated at Posted at 2017-05-31
mcp23017_node_input.js
#! /usr/local/bin/node
//
//  mcp23017_node_input.js
//
//                  May/31/2017
//
// ------------------------------------------------------------------
function read_proc (wire)
{
    wire.readBytes(0x13, 1, function(err, res)
    {
    console.log (res)

    console.log (res[0].toString(16))
    console.log ("*** end ***")
    })
}

// ------------------------------------------------------------------
console.log ("*** start ***")
var i2c = require('i2c')
const address = 0x20
var wire = new i2c(address, {device: '/dev/i2c-1'})
    // point to your i2c address, debug provides REPL interface 

wire.writeBytes(0x01, [0xff], function(err, res)
    {
    wire.writeBytes(0x0d, [0xff], function(err, res)
        {
        read_proc (wire)
        })
    })

// ------------------------------------------------------------------
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0