ShiftOut issue.

Hi everyone. I am working currently with two 8-Bit 74HC164D Shift Registers that are driving 2x4 7segment displays connected together. However, i have an issue, while i can output correct bits to light up the segments and display corresponding digits, i can not control where they light up... How could i fix this issue, please help me. (I am using Arduino to program it)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
int dataPin = 2;
int clockPin = 3;

void setup() {

  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
}

// digit 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
// 0 bit to light up a segment  0     1     2     3     4     5     6     7     8     9
unsigned char LED_ARRAY[] = { 0XC0, 0xF9, 0XA4, 0XB0, 0X99, 0X92, 0X82, 0XF8, 0X80, 0X90 };


void loop() {

  for (byte i = 0; i < 10; i++) {
    shiftOut(dataPin, clockPin, MSBFIRST, LED_ARRAY[i]);
    delay(600);
  }
}

void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t value)
{
  uint8_t i;

  for (i = 0; i < 8; i++)  {
    digitalWrite(dataPin, (value & (1 << (7 - i))));
    digitalWrite(clockPin, HIGH);
    digitalWrite(clockPin, LOW);
  }
}
Last edited on
Anyone please?
Topic archived. No new replies allowed.