Hello,
So I am currently using arduino IDE to program the Raspberrypi Pico W. I have connected a tca9548a multiplexer to the pico W so I can control 4 independent LCDs. For your reference, I am using the LCDs from here: https://akizukidenshi.com/catalog/g/g112486/ they are 16x2 backlit LCDs.
I am now trying to display info on all 4 simultaneously. The first line in all the LCDs are just static dots. The second lines in all LCDs display different text and continuously scroll right in a loop. While building this, I tried the LCDs one by one and in the code I will share now, I combined all 4 LCDs in one code. Now all the LCDs are displaying text but the issue is that they are either too slow, or are displaying only partial text, or displaying weird alphabets. The reason I am wondering if there is a problem is that when I only have one LCD following this code, there is no lag or issues mentioned. but the more LCDs I add, the worse these problems get. I do not know what steps to take to fix this. Should I perhaps place step up resistors? or will a change in the code make it faster?
I have attached the code here:
#include <ST7032_asukiaaa.h>
#include "Wire.h" // For I2C
//#include "LCD.h" // For LCD
// Added library*
#define TCA9548A_ADDR 0x70
#define LCD_ADDR 0x3e
// TCA9548A Encoder address
ST7032_asukiaaa lcd; // Set the LCD I2C address
char text[] = " blue ";
char text2[] = " LESSGOO ";
char text3[] = "work once more!";
char text4[] = "one last";
void selectChannel(uint8_t channel) {
if (channel > 7) return;
Wire.beginTransmission(TCA9548A_ADDR);
Wire.write(1 << channel);
Wire.endTransmission();
delay(100);
lcd.begin(0x3e, 16, 2);
}
void setup() {
Wire.begin();
Serial.begin(9600);
delay(3000);
for (uint8_t channel = 0; channel < 8; channel++) {
selectChannel(channel); // Select the channel
delay(100); // Allow time for the device to respond
Wire.beginTransmission(LCD_ADDR);
uint8_t error = Wire.endTransmission();
if (error == 0) {
Serial.print("LCD detected at channel ");
Serial.println(channel);
} else {
Serial.print("No device detected at channel ");
Serial.println(channel);
}
}
}
void loop(){
//DISPLAY 1
selectChannel(7);
static int startIndex = 0;
int textLength = strlen(text);
lcd.clear();
// Print the text starting from the calculated index
lcd.setCursor(0,0);
lcd.print(".....");
lcd.setCursor(0, 1);
// Print the first part of the text
for (int i = 0; i < 16; i++) {
int currentIndex = (startIndex + i) % textLength;
lcd.print(text[currentIndex]);
}
startIndex = (startIndex + 1) % textLength; // Update the start index for the next iteration
delay(400); // Adjust the speed of scrolling here
//DISPLAY 2
selectChannel(2);
static int startIndex2 = 0;
int text2Length = strlen(text2);
lcd.clear();
// Print the text starting from the calculated index
lcd.setCursor(0,0);
lcd.print(".....");
lcd.setCursor(0, 1);
// Print the first part of the text
for (int i = 0; i < 16; i++) {
int currentIndex2 = (startIndex2 + i) % text2Length;
lcd.print(text2[currentIndex2]);
}
startIndex2 = (startIndex2 + 1) % text2Length; // Update the start index for the next iteration
delay(300); // Adjust the speed of scrolling here
//DISPLAY 3
selectChannel(1);
static int startIndex3 = 0;
int text3Length = strlen(text3);
lcd.clear();
// Print the text starting from the calculated index
lcd.setCursor(0,0);
lcd.print(".....");
lcd.setCursor(0, 1);
// Print the first part of the text
for (int i = 0; i < 16; i++) {
int currentIndex3 = (startIndex3 + i) % text3Length;
lcd.print(text3[currentIndex3]);
}
startIndex3 = (startIndex3 + 1) % text3Length; // Update the start index for the next iteration
delay(500); // Adjust the speed of scrolling here
//DISPLAY 4
selectChannel(0);
static int startIndex4 = 0;
int text4Length = strlen(text4);
lcd.clear();
// Print the text starting from the calculated index
lcd.setCursor(0,0);
lcd.print(".....");
lcd.setCursor(0, 1);
// Print the first part of the text
for (int i = 0; i < 16; i++) {
int currentIndex4 = (startIndex4 + i) % text4Length;
lcd.print(text4[currentIndex4]);
}
startIndex4 = (startIndex4 + 1) % text4Length; // Update the start index for the next iteration
delay(500); // Adjust the speed of scrolling here
}
I have also attached pictures of the circuit. it is messier than it looks. The 3.3V, Ground, SDA and SCL pins of the Pico W are connected to their counterparts on the Multiplexer. From the multiplexer, the SDA and SCL pins of all the LCDs are connected to respective SDA and SCL pins 0,1,2,7. They are also connected to the ground and power. it is a very simple circuit actually. All the circuits of the LCDs are correct since I tested this configuration with different code. but if you think a change will help, I am happy to try it.




