I've recently gotten into the mcp23017 microchip for port expansion. In my initial test, I had a circuit with 5 buttons and 4 leds working consistently on an Arduino Uno. I ported it over to an Arduino Zero and also an Arduino MKRZero, but neither of them worked. I ended up trimming down the circuit quite a bit to just barebones chip detection / setup, and then adding one single LED. Still, it wouldn't work. With one single LED, it was very sometime-ish (mcp would sometimes configure, sometimes not), and as soon as I added anything more, it would behave very erratically.
For reference, I'm using the Adafruit_MCP23X17 library, and regular mcp23017 chips. The following code works without fail on the Uno:
Code: Select all
#include <Adafruit_MCP23X17.h>
#include <Stepper.h>
// initialise mcp
Adafruit_MCP23X17 mcp;
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Welcome to the candy machine");
// init mcp
if (!mcp.begin_I2C(0x20)) {
Serial.println("Error initialising mcp");
while (1);
}
// assign leds as outputs
mcp.pinMode(8, OUTPUT);
}
void loop() {
mcp.digitalWrite(8, HIGH);
}
- On the Uno, I'm powering from computer.
- On the Zero, I'm using the programming port for uploading code to the Arduino, and the barrel jack to supply 12V to the device.
Would love any input or feedback on this one, as I can't find much out there on the interwebs!