Daisy chaining two 4 x 7 segment 4-bit LED modules

Firstly, can I say this is my 1st post on here and i’m relatively new to the arduino and with limited programming skills but so far enjoying the frustrations of learning, so please bear with me.
I purchased a couple of these 4-bit LED digital tube modules and with the help of searching this forum I have managed to get a single module working and displaying whatever my 4 variables holds.

What i’m now trying to achieve is to daisy chain two of these modules so I can display 8 single digit variables.

I have soldered the two together, as per image using gnd-gnd dio-qh rclk-rclk sclk-sclk vcc-vcc.

With the code I have, I can choose which module to display on by setting the digit var to 0 or 4, but it is just mirrored to the other module. How can I changed the code so it will display all 8 variables 0-8?

Many thanks in advance.

const int clock = 7; //SCK
const int latch = 5; //RCK 
const int data = 6;  //DIO

   unsigned char LED_0F[] = 
    {// 0   1    2    3  4  5    6    7  8  9    A    b  C    d    E    F    -
     0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E, 0xbf, 0x7F, 0xFF
    };
    unsigned char LED[8];
    
    int SCLK = 7;
    int RCLK = 5;
    int DIO = 6;

void setup ()
    {
      Serial.begin(9600);
      pinMode(SCLK,OUTPUT);
      pinMode(RCLK,OUTPUT);
      pinMode(DIO,OUTPUT);
    }

    void loop()
    {

   LED[7] = 1;
   LED[6] = 2;
   LED[5] = 3;
   LED[4] = 4;
   LED[3] = 5;
   LED[2] = 6;
   LED[1] = 7;
   LED[0] = 8;
   LED4_Display ();
    }

void LED4_Display (void)
    { 
        byte digit = 4;
        for (byte dselect = 1; dselect < 0x10; dselect = dselect << 1)
        {
            LED_OUT(LED_0F[LED[digit]]);
            LED_OUT(dselect);
            digitalWrite(RCLK, LOW);
            digitalWrite(RCLK, HIGH);
            ++digit;
        }
    }

    void LED_OUT(unsigned char X)
    {
      unsigned char i;
      for(i=8;i>=1;i--)
      {
          if (X&0x80) 
            {
                digitalWrite(DIO,HIGH);
            }  
            else 
            {
                 digitalWrite(DIO,LOW);
            }
        X<<=1;
        digitalWrite(SCLK,LOW);
        digitalWrite(SCLK,HIGH);
      }
    }

Try this:

const int clock = 7; //SCK
const int latch = 5; //RCK
const int data = 6;  //DIO

unsigned char LED_0F[] =
{ // 0   1    2    3  4  5    6    7  8  9    A    b  C    d    E    F    -
  0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E, 0xbf, 0x7F, 0xFF
};
unsigned char LED[8];

int SCLK = 7;
int RCLK = 5;
int DIO = 6;

void setup ()
{
  Serial.begin(9600);
  pinMode(SCLK, OUTPUT);
  pinMode(RCLK, OUTPUT);
  pinMode(DIO, OUTPUT);
}

void loop()
{

  LED[7] = 1;
  LED[6] = 2;
  LED[5] = 3;
  LED[4] = 4;
  LED[3] = 5;
  LED[2] = 6;
  LED[1] = 7;
  LED[0] = 8;
  LED4_Display ();
}

void LED4_Display (void)
{
  byte digit = 4;
  for (byte dselect = 1; dselect < 0x10; dselect = dselect << 1)
  {
    LED_OUT(LED_0F[LED[digit]]);
    LED_OUT(dselect);
    LED_OUT(LED_0F[LED[digit-4]]);
    LED_OUT(dselect);
    digitalWrite(RCLK, LOW);
    digitalWrite(RCLK, HIGH);
    ++digit;
  }
}

void LED_OUT(unsigned char X)
{
  unsigned char i;
  for (i = 8; i >= 1; i--)
  {
    if (X & 0x80)
    {
      digitalWrite(DIO, HIGH);
    }
    else
    {
      digitalWrite(DIO, LOW);
    }
    X <<= 1;
    digitalWrite(SCLK, LOW);
    digitalWrite(SCLK, HIGH);
  }
}

Horrible code, by the way…

Many thanks Paul for not only taking the time to reply but also for providing a working solution. The code in void loop is just for testing purposes. Which other parts of the code are messy, and what would be the cleanest way of writing it. My part of learning at the moment is scrapping code and then trying to understand it.

Well, for example there are some variables declared at the top of the sketch that are not used.

Have a look atShiftOut() to replace your LED_OUT() function.

Hopefully it looks better now Paul. I now need to spend time understanding what it’s all doing. Your help has been greatly appreciated.

const int clockPin = 7; // SCLK
const int latchPin = 5; // RCLK
const int dataPin = 6; //DIO

  unsigned char LED_0F[] = 
    {// 0   1     2     3     4     5      6    7     8     9     A     b     C     d     E     F     -
     0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90, 0x88, 0x83, 0xA7, 0xA1, 0x86, 0x8E, 0xbf, 0x7F, 0xFF
    };
    unsigned char LED[8];
    
    
void setup ()
    {
      Serial.begin(9600);
      pinMode(clockPin,OUTPUT);
      pinMode(latchPin,OUTPUT);
      pinMode(dataPin,OUTPUT);
    }

    void loop()
    {

   LED[7] = 5;
   LED[6] = 6;
   LED[5] = 7;
   LED[4] = 8;
   LED[3] = 1;
   LED[2] = 2;
   LED[1] = 3;
   LED[0] = 4;
   LED8_Display ();
    }

void LED8_Display (void)
    { 
        byte digit = 4;
        for (byte dselect = 1; dselect < 0x10; dselect = dselect << 1)
        {
           int a = LED_0F[LED[digit]];
           int b = dselect;
           int c = LED_0F[LED[digit-4]];
           
            digitalWrite(latchPin, LOW);
            shiftOut(dataPin, clockPin, MSBFIRST, a);
            shiftOut(dataPin, clockPin, MSBFIRST, b);
            shiftOut(dataPin, clockPin, MSBFIRST, c);
            shiftOut(dataPin, clockPin, MSBFIRST,b); 
            digitalWrite(latchPin, HIGH);
            ++digit;
        }
    }

You still have those variables at the top that are not used:

const int clockPin = 7; // SCLK
const int latchPin = 5; // RCLK
const int dataPin = 6; //DIO

Are they not holding the pin numbers to pass to the shiftout and adding something more descriptive than just the numbers?

Ah, sorry! I had not spotted that you had removed these lines:

int SCLK = 7;
int RCLK = 5;
int DIO = 6;

Yes, I didn't notice when I first posted that they had been duplicated. A touch of code blindness kicked it.