Hi everyone.
The code from: no matching function for call to TwoWire::begin(int, int) got ERROR, WHY?
#include <Wire.h>
int pinSDA = 5; // esp32
int pinSCL = 4;
// int pinSDA = 20; //ATMega2560
// int pinSCL = 21;
void setup()
{
Wire.begin(5, 4);
Serial.begin(9600);
while (!Serial);
Serial.println("\nI2C Scanner");
}
void loop() {
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
// for(address = 1; address < 127; address++ ) {
for ( int address = 0x00; address < 0x80; address++) {
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address < 16)
{
Serial.print("0");
}
Serial.println(address, HEX);
nDevices++;
}
else if (error == 4)
{
Serial.print("Unknow error at address 0x");
if (address < 16) {
Serial.print("0");
}
Serial.println(address, HEX);
}
}
if (nDevices == 0) {
Serial.println("No I2C devices found\n");
}
else {
Serial.println("done\n");
}
delay(5000);
}
ERROR:
Arduino: 1.8.19 (Windows 7), Board: "Arduino Uno"
C:\Users\HUA.DELLV-PC\Documents\Arduino\I2C_Scanner_M\I2C_Scanner_M.ino: In function 'void setup()':
I2C_Scanner_M:13:18: error: no matching function for call to 'TwoWire::begin(int, int)'
Wire.begin(5, 4);
^
In file included from C:\Users\HUA.DELLV-PC\Documents\Arduino\I2C_Scanner_M\I2C_Scanner_M.ino:5:0:
C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src/Wire.h:53:10: note: candidate: void TwoWire::begin()
void begin();
^~~~~
C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src/Wire.h:53:10: note: candidate expects 0 arguments, 2 provided
C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src/Wire.h:54:10: note: candidate: void TwoWire::begin(uint8_t)
void begin(uint8_t);
^~~~~
C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src/Wire.h:54:10: note: candidate expects 1 argument, 2 provided
C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src/Wire.h:55:10: note: candidate: void TwoWire::begin(int)
void begin(int);
^~~~~
C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src/Wire.h:55:10: note: candidate expects 1 argument, 2 provided
exit status 1
no matching function for call to 'TwoWire::begin(int, int)'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
