How to connect two LCDs to Arduino

 In this project, we are going to tell you who is to connect two 16x2 LCDs together to one Arduino board. This configuration is useful in many ways when you need to display large amounts of information, for example, or when you need to display the same information in different places or at different angles.


How to connect two LCDs to Arduino

In this case, we have implemented the project so that the text that will be displayed on one LCD will be automatically transferred to another LCD. The total number of pins that need to be connected to a 16x2 LCD from Arduino Nano is 12.


When we connect two LCDs with a total of 24. Within a 16x2 LCD, 6 pins are used for data transmission. In our case, we only connected 14 lines of the LCD with the Arduino Nano, in which 12 pins are used for data transfer.


The basic connection diagram is shown in the following figure.


How to connect two LCDs to Arduino

The Arduino program code for controlling two LCDs is shown below.



#include <LiquidCrystal.h>
LiquidCrystal lcd2(12, 11, 1, 2, 3, 4);
LiquidCrystal lcd1(0, 10, 8, 7, 6, 5);

char * LargeText = "Connecting 2 - 16*2 LCD with Arduino";
int iLineNumber = 1;                                                                
int iCursor = 0;

void setup() 
{
  
  lcd1.begin(16, 2);                                                          
  lcd2.begin(16, 2);
  lcd1.clear();
  lcd2.clear();
  
}
void loop() 
{
  
  UpdateLCDDisplay();                                                              
  delay(160);                                                                      
  lcd1.clear();
  lcd2.clear();
  delay(60);
  
}

void UpdateLCDDisplay()
{
  int iLenOfLargeText = strlen(LargeText);                                         
  if (iCursor == (iLenOfLargeText - 1) )                                            
{
   iCursor = 0;
}
  lcd1.setCursor(0,iLineNumber);
  lcd2.setCursor(0,iLineNumber);
  if(iCursor < iLenOfLargeText - 32)                                             
{
  for (int iChar = iCursor; iChar < iCursor + 16 ; iChar++)
{
  lcd1.print(LargeText[iChar]);
}
  for (int iChar = iCursor + 16 ; iChar < iCursor + 32 ; iChar++)
{
  lcd2.print(LargeText[iChar]);
}
}
  else
{
  for (int iChar = iCursor; iChar < (iLenOfLargeText - 1) ; iChar++)           
{
  if(16 > (iChar - iCursor))
{
  lcd1.print(LargeText[iChar]);
}
  else
{
  lcd2.print(LargeText[iChar]);
}
}
  for (int iChar = 0; iChar <= 32 - (iLenOfLargeText - iCursor); iChar++)       
{
  if(16 > (32 - (iLenOfLargeText - iCursor)))
{
  lcd2.print(LargeText[iChar]);
}
  else
{
  if( ((32 - (iLenOfLargeText - iCursor)) - 16) >=  iChar)
{
  lcd1.print(LargeText[iChar]);
}
  else
{
  lcd2.print(LargeText[iChar]);
}
}  
}
}
  iCursor++;
}
Previous Post Next Post

Contact Form