# Driving a multiplexed segment LCD... How?

I have a multiplexed segment LCD which has 3 COM pins and requires a frequency= 64Hz, 25% duty, 1/3 bias; see below for pinouts. After looking around, I found this interesting post where the poster drives a similar display but in his case, it has 4 COM pins.

Can anybody help me scale his sketch to just 3 COM pins? Thanks in advance.

The original post is here. This is his sketch.

``````#include <Streaming.h>
#define cout Serial
#define endl '\n'
const int BP1=7, BP2=9, BP3=8, BP4=10; //backplanes
int S1=11, S2=6, S3=12; //segment outputs.  S1 is always blanked, S2&3 are driven

void setup()
{
Serial.begin(19200);
cout <<"Hello from the clock LCD test mule \n";
pinMode(S1,OUTPUT); pinMode(S2,OUTPUT);pinMode(S3,OUTPUT); //segments are live
}

void loop(){
int displaydigit= (millis()/1000)%11; //test pattern cycles from 0 to 10
drivelcd(displaydigit);
}

void drivelcd(int digit){ //drive the LCD to display a digit
//each of the LCD backplanes is cycled low then high for 4ms while the others are held at a middle-voltage
//the segments are lit by setting them opposite to the active backplane
//each bit in the digit segment table below defines the state of a segment for a particular backplane for that digit
//the segment 2 bits are first then the segment 3 bits
//e.g. for a 0(the 1st element) segment 2 is on for backplanes 2 and 4 (0101) and segment 3 is on for all of them(1111)
const unsigned char dst[]={0b01011111,0b00000110,0b00111101,0b00101111,0b01100110,0b01101011,0b01111011,0b00001110,0b01111111,0b01101110,0b01111110}; //digits 0-A
static int stateprev=8; //tells us when we change states
int statenow=(millis()/4)&0x07; //cycles from 0-7 changing every 4 ms
if (statenow!=stateprev){ //if the state has changed
//reset backplane pins to input and activate the pull-up resistors
pinMode(BP1,INPUT); pinMode(BP2,INPUT);  pinMode(BP3,INPUT);pinMode(BP4,INPUT);
digitalWrite(BP1,HIGH);digitalWrite(BP2,HIGH);digitalWrite(BP3,HIGH);digitalWrite(BP4,HIGH);
switch (statenow) {
case 0:
pinMode(BP1,OUTPUT); digitalWrite(BP1,LOW); //activate backplane 1 for 1st half of its cycle
digitalWrite(S1,LOW); //ensure segment 1 stays blank
digitalWrite(S2,(dst[digit]&0x80)>>7); //activate segment 2 if needed
digitalWrite(S3,(dst[digit]&0x08)>>3); //activate segment 3 if needed
break;
case 1:
pinMode(BP1,OUTPUT); digitalWrite(BP1,HIGH); //set BP1 2nd half of its cycle
digitalWrite(S1,HIGH); //ensure segment 1 stays blank
break;
case 2:
pinMode(BP2,OUTPUT); digitalWrite(BP2,LOW); //set BP2 1st half of its cycle
digitalWrite(S1,LOW); //ensure segment 1 stays blank
digitalWrite(S2,(dst[digit]&0x40)>>6); //activate segment 2 if needed
digitalWrite(S3,(dst[digit]&0x04)>>2); //activate segment 3 if needed
break;
case 3:
pinMode(BP2,OUTPUT); digitalWrite(BP2,HIGH); //set BP2 2nd half of its cycle
digitalWrite(S1,HIGH); //ensure segment 1 stays blank
break;
case 4:
pinMode(BP3,OUTPUT); digitalWrite(BP3,LOW); //set BP3 1st half of its cycle
digitalWrite(S1,LOW); //ensure segment 1 stays blank
digitalWrite(S2,(dst[digit]&0x20)>>5); //activate segment 2 if needed
digitalWrite(S3,(dst[digit]&0x02)>>1); //activate segment 3 if needed
break;
case 5:
pinMode(BP3,OUTPUT); digitalWrite(BP3,HIGH); //set BP3 2nd half of its cycle
digitalWrite(S1,HIGH); //ensure segment 1 stays blank
break;
case 6:
pinMode(BP4,OUTPUT); digitalWrite(BP4,LOW); //set BP4 1st half of its cycle
digitalWrite(S1,LOW); //ensure segment 1 stays blank
digitalWrite(S2,(dst[digit]&0x10)>>4); //activate segment 2 if needed
digitalWrite(S3,(dst[digit]&0x01)>>0); //activate segment 3 if needed
break;
case 7:
pinMode(BP4,OUTPUT); digitalWrite(BP4,HIGH); //set BP4 2nd half of its cycle
digitalWrite(S1,HIGH); //ensure segment 1 stays blank