I'm building a modified open source liquid handling robot based on evobot using ramps hardware. While testing, it's not registering the MCP23017 chip that it's using for I/O expansion. I'm trying to write a program to test to see if the chip is working at all. Preferably I can have an output toggle between high and low that I can test with a multimeter or alternately I can add an LED. Please tell me that there's something wrong with my code, I'm getting the fail notification each time. https://bitbucket.org/afaina/evobliss-software/wiki/Home
#include <Wire.h>
#include "Adafruit_MCP23X17.h"
Adafruit_MCP23X17 mcp;
void setup() {
Serial.begin(9600);
mcp.begin_I2C(); // use default address 0
if (!mcp.begin_I2C())
{
Serial.println("fail");
while(1);
}
mcp.pinMode(8, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT); // use the p13 LED as debugging
}
void loop() {
mcp.digitalWrite(8,HIGH);
digitalWrite(LED_BUILTIN,HIGH);
delay(1000);
mcp.digitalWrite(8,LOW);
digitalWrite(LED_BUILTIN,LOW);
delay(1000);
}
Did you look at the mcp23017 examples that come with the library?
mcp.begin_I2C(); // use default address 0
if (!mcp.begin_I2C())
{
Serial.println("fail");
while(1);
}
mcp.pinMode(8, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT); // use the p13 LED as debugging
}
You do realize you called mcp.begin() twice, don't you?
And, I don't believe you'll find it at address zero. Addresses 0x20 through 0x27 are where they usually are. IF you haven't set any jumpers, it's probably at 0x27.
Pull ups are located on the ramps board that is powering it. No idea why there is a voltage divider as I didn't design this but I do know that the design has previously worked.