The Adafruit library does not support using SoftwareWire. It is hardcoded to use the Wire library.
When using the hd44780 library and SoftwareWire, you won't ever include <Wire.h> if you are creating a Wire Object - as you have done.
To use SoftWire this way, you include SoftwareWire and create the Wire object before you include the hd44780 header files.
While there is a way to use Wire and SoftwareWire at the same tine,
I2c is a bus, and you can have multiple slaves on it.
I would just remove the SoftwareWire stuff and control both devices on the same i2c bus controlled by the Wire library.
Yes, that is the problem
I'm a newbie and I don't know how to use (Wire) to set pins
Can you help me modify my code and based on your modification I will try to understand things
It's just a code I got from a thread
All I want is to set screen pins
Use his library (hd44780)
I want to change the default pins with special pins like D2 and D3
"microcontroller" refers to a board like the Arduino Uno, Nano, Mega, ESP8266, ESP32.
a "I2C Arduino Serial Module for LCD" ... might be a I2C port expander only - that's not a microcontroller.
Again: Which microcontroller are you using?
either
a) chose another microcontroller like an Arduno Mega or an Arduino NANO with more analog pins and use, the desginated pins for I2C
b) use an I2C portexpander/ADC, to expand the analog inputs and use the desginated pins for I2C
c) rewrite the Adafruit Library to make it work with Soft-Wire.
I would go for option A. Even an Arduino Nano might be sufficent.
An electronic circuit based on (Arduino Nano China) is designed and D2,D3 is customized for I2C Arduino Serial Module for LCD and it is difficult to modify the hardware
We just want to modify the software to fit the scheme
I found his library LiquidCrystal_Software_I2C I set pins the pins
and that other LCD library would work for you togehter with the Adafruit INA219 Library at the same time (beside some faults in the last two lines I guess)?
An electronic circuit based on (Arduino Nano China) is designed and D2,D3 is customized for I2C Arduino Serial Module for LCD and it is difficult to modify the hardware
We just want to modify the software to fit the scheme
I found his library LiquidCrystal_Software_I2C I set pins the pins
Adafruit_INA219 is hardcoded to use the Wire library.
The Arduino.cc Wire library for AVR based boards that comes bundled with the IDE does not support changing the pins used.
You can run both the INA219 and the lcd on the same i2c bus using the Wire library, but depending on how the pins are mapped, it may not allow you use all the analog pins.
I'm not sure which board you have and how the i2c pins are mapped.
One thing that may help is if you run the I2CexpDiag sketch that is included with the hd44780 library.
It will print out information about your board and the i2c pins used by the Wire library.
Here is a project where I changed the library files: https://wokwi.com/arduino/projects/307841659182252608.
I took the "LiquidCrystal_I2C.cpp" and "LiquidCrystal_I2C.cpp" and copied them into my project. I changed the names of the files.
Then I added a pointer to a I2C object to the class of the display.
I changed the code of the display, the pointer to the I2C object is copied in the constructor function and the code uses that pointer for the I2C functions.
class LiquidCrystal_I2C : public Print {
public:
LiquidCrystal_I2C(SoftwareWire * softwire, uint8_t lcd_Addr,uint8_t lcd_cols,uint8_t lcd_rows);
private:
SoftwareWire * _swire;
};
I could not find a LCD library that made it easier.
Perhaps there is a LCD library that already uses its own software implementation for the I2C. If you find such a library, please give a link to it, so I can have a look at it.