Hi,
I have connected a port expander MCP23017 to pixl.js using I2c (using D5 for scl : D5 and D4 for sda)
My target is to use MCP 23017 for reading or writing some signal.
There are instructions in https://www.espruino.com/MCP23xxx but it doesn't work for reading or writing:
It doesn't reports error messages, here is the code:
var i2c = new I2C();
i2c.setup({ scl : D5, sda: D4 });
var address = 0x20; //this is the address, set by the address pins.
// for MCP23017
var port=require("MCP23017").connect(i2c,null,address);
port.B0.mode('output');
port.B0.write(1); //<--IT MUST CHANGE TO '1' BUT B0 CONTINUE AT '0' LEVEL
port.A0.mode('input_pullup');
console.log(port.A0.read()); //<--ALWAYS READ '1'
I wrote a new code and now is working just for reading signals:
var i2c = new I2C();
i2c.setup({ scl : D5, sda: D4 });
i2c.writeTo(0x20, 0X12);
var x = i2c.readFrom(0x20, 1);
i2c.writeTo(0x20, 0X13);
var y = i2c.readFrom(0x20, 1);
But for writing , it doesn't work:
var i2c = new I2C();
i2c.setup({ scl : D5, sda: D4});
i2c.writeTo(0x20, 0x00);
i2c.writeTo(0x20, 0x12); // program all Bank A to output
i2c.writeTo(0x20, 0x00);
i2c.writeTo(0x20, 0x00);
i2c.writeTo(0x20, 0x12); // Change all pins of Bank A to '1'
i2c.writeTo(0x20, 0xFF);
i2c.writeTo(0x20, 0x13); // program all Bank B to output
i2c.writeTo(0x20, 0x00);
i2c.writeTo(0x20, 0x00);
i2c.writeTo(0x20, 0x13); // Change all pins of Bank B to '1'
i2c.writeTo(0x20, 0xFF);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi,
I have connected a port expander MCP23017 to pixl.js using I2c (using D5 for scl : D5 and D4 for sda)
My target is to use MCP 23017 for reading or writing some signal.
There are instructions in https://www.espruino.com/MCP23xxx but it doesn't work for reading or writing:
It doesn't reports error messages, here is the code:
I wrote a new code and now is working just for reading signals:
But for writing , it doesn't work:
Some help, please?
Thans in advance.
Paco