-
Notifications
You must be signed in to change notification settings - Fork 39
Description
At first I had errors with the I²C communication. I find that with ESP32 we must use pins 21 and 22 for SDA and SCL.
So the I²C communication works now.
But I can't read input of buttons added on the SX1509 board, or turn on a LED.
Remark : I tested the SX1509 on an Arduino UNO and it works.
This is my code (I use Arduino IDE) :
#define I2C_SDA 21
#define I2C_SCL 22
const byte SX1509_ADDRESS = 0x3E;
SX1509 sx1509io;
in setup() :
Wire.begin(I2C_SDA, I2C_SCL);
if (sx1509io.begin(SX1509_ADDRESS) == false) {
Serial.println("Failed to communicate. Check wiring and address of SX1509.");
}
//LED on pin 15
sx1509io.pinMode(15, OUTPUT);
// Blink the LED a few times before we start:
for (int i = 0; i < 5; i++) {
sx1509io.digitalWrite(15, HIGH);
delay(100);
sx1509io.digitalWrite(15, LOW);
delay(100);
}
//Button on pin 0
sx1509io.pinMode(0, INPUT_PULLUP);
in loop() :
if (sx1509io.digitalRead(0) == LOW) {
Serial.println("button1 pushed !!!");
}