Wednesday, March 25, 2015

More progress with the displays


I have both displays hooked up and working independently now, and like I had hoped, it only takes 7 output pins to drive both displays.

Here is how they are wired

LCD Pin Arduino Pin
1 Logic Gnd Gnd
2 Logic +5V +5V
3 Contrast Pot sweep
4 RS Pin 6
5 RW Gnd
6 EN (LCD1) Pin 7
6 EN (LCD 2) Pin 8
7
8
9
10
11 DB4 Pin 9
12 DB5 Pin 10
13 DB6 Pin 11
14 DB7 Pin 12
15 Backlight +5V +5V
16 Backlight Gnd Gnd

I used one potentiometer to control the contrast on both displays.  All of the connections go to both displays except the enable which has pin 7 going to display 1 and pin 8 going to display 2.

Sample Sketch

I used the following sketch to test that I had both displays wired correctly.  Notice that I had to define the pinouts for LCD1 and LCD2.


#include <LiquidCrystal.h>

LiquidCrystal lcd1(6,7,9,10,11,12);
LiquidCrystal lcd2(6,8,9,10,11,12);

void setup() {
  // put your setup code here, to run once:
lcd1.begin(20, 4);
lcd2.begin(20, 4);

 lcd1.print("Player 1");
 lcd2.print("Player 2");

}

void loop() {
  // put your main code here, to run repeatedly:
 lcd1.setCursor(0,1);
 lcd1.print(millis()/1000);
 delay(1000);
 lcd2.setCursor(0,1);
 lcd2.print(millis()/1000);
 delay(1000);
}

No comments:

Post a Comment