0
votes

Ive got a ESP32-S2 and just try to test the circuit and the Board with this simple script. Error Code says.

ziel_19-09-2020.ino: In function 'void setup()': ziel_19-09-2020:85:18: error: call of overloaded 'begin(int)' is ambiguous mcp1.begin(addr1); ^ In file included from C:\Users/Arduino\ziel_19-09-2020\ziel_19-09-2020.ino:1: C:\Users\Arduino\libraries\Adafruit_MCP23017_Arduino_Library/Adafruit_MCP23017.h:26:8: note: candidate: 'void Adafruit_MCP23017::begin(uint8_t, TwoWire*)' void begin(uint8_t addr, TwoWire theWire = &Wire); ^~~~~ C:\Users\Arduino\libraries\Adafruit_MCP23017_Arduino_Library/Adafruit_MCP23017.h:27:8: note: candidate: 'void Adafruit_MCP23017::begin(TwoWire)' void begin(TwoWire *theWire = &Wire); ^~~~~ exit status 1 call of overloaded 'begin(int)' is ambiguous

The code is this

    #include <Adafruit_MCP23017.h>
#include <math.h> 
#include <Wire.h>
#include <Adafruit_NeoPixel.h>
#include "SPI.h" 

#define BUTTON_PIN   2   
#define PIXEL_PIN    6  
#define PIXEL_COUNT 136

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

Adafruit_MCP23017 mcp1;
Adafruit_MCP23017 mcp2;
Adafruit_MCP23017 mcp3;
Adafruit_MCP23017 mcp4;
Adafruit_MCP23017 mcp5;
Adafruit_MCP23017 mcp6;
Adafruit_MCP23017 mcp7;
Adafruit_MCP23017 mcp8;

///////////////////////////////////
/////////////Settings//////////////
///////////////////////////////////


int dotcolor_1=0;   
int dotcolor_2=250;
int dotcolor_3=0;

int circlecolor_1=250;
int circlecolor_2=0;
int circlecolor_3=0;

int time_hold=500;
int dtime=3;
///////////////////////////////////
/////////////Settings end//////////
///////////////////////////////////



#define addr1 0
#define addr2 1
#define addr3 2
#define addr4 3
#define addr5 4
#define addr6 5
#define addr7 6
#define addr8 7


double w=0;
double xd;
double yd;
boolean sensor_1[13];
boolean sensor_2[12];
boolean sensor_3[12];
boolean sensor_4[12];
boolean sensor_5[12];
boolean sensor_6[12];
boolean sensor_7[12];
boolean sensor_8[12];

int sen1[12];
int sen2[12];
int sen3[12];
int sen4[12];
int sen5[12];
int sen6[12];
int sen7[12];
int sen8[12];

uint16_t sensor1;
uint16_t sensor2;
uint16_t sensor3;
uint16_t sensor4;
uint16_t sensor5;
uint16_t sensor6;
uint16_t sensor7;
uint16_t sensor8;

void setup() {  
  strip.begin();
 mcp1.begin(addr1);
 mcp2.begin(addr2);
 mcp3.begin(addr3);
 mcp4.begin(addr4);
 mcp5.begin(addr5);
 mcp6.begin(addr6);
 mcp7.begin(addr7);
 mcp8.begin(addr8);

  for(int i=0;i<=15;i++){
  mcp1.pinMode(i, INPUT);
  mcp2.pinMode(i, INPUT);
  mcp3.pinMode(i, INPUT);
  mcp4.pinMode(i, INPUT);
  mcp5.pinMode(i, INPUT);
  mcp6.pinMode(i, INPUT);
  mcp7.pinMode(i, INPUT);
  mcp8.pinMode(i, INPUT);
}
2

2 Answers

2
votes

If you use #define addr1 0 the compiler can't choose between begin(pointer) and begin(int), because the value from #define could be a pointer.

If you set the I2C address as typed constant of type uint8_t, which is the type of the address parameter in the begin function with I2C address, the compiler will use the right function.

So set the addresses this way const uin8_t addr1 = 0;

-1
votes

Basically, the Adafruit_MCP23017 library is bad. You may need to edit the library. There are actually two begin functions that you could potentially be calling, and Arduino has no idea which one you want.

Option 1:
You could add the following line outside of setup():

#define Wire TinyWireM

and changing your begin functions to:

 mcp1.begin(addr1, &Wire);
 mcp2.begin(addr2, &Wire);
 mcp3.begin(addr3, &Wire);
 mcp4.begin(addr4, &Wire);
 mcp5.begin(addr5, &Wire);
 mcp6.begin(addr6, &Wire);
 mcp7.begin(addr7, &Wire);
 mcp8.begin(addr8, &Wire);

Option 2:
Currently, the two begin functions in the library look like this:

  void begin(uint8_t addr, TwoWire *theWire = &Wire);
  void begin(TwoWire *theWire = &Wire);

My recommendation above is based on the assumption that you are using the first function.

Your second option would be to remove the second function.

Remove the following from Adafruit_MCP23017.cpp (starting form line 133):

/**
 * Initializes the default MCP23017, with 000 for the configurable part of the
 * address
 * @param theWire the I2C object to use, defaults to &Wire
 */
void Adafruit_MCP23017::begin(TwoWire *theWire) { begin(0, theWire); }

Remove the following from Adafruit_MCP23017.h (line 27):

  void begin(TwoWire *theWire = &Wire);

I can further guide you in editing the library if needed