Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: ze3one on Nov 26, 2011, 03:19 am

Title: led multiplexing
Post by: ze3one on Nov 26, 2011, 03:19 am
Hi, I'm multiplexing some led, so I started with 4 * 4, anode in \\ cathode in \\ with 1k resistor and I'm using an 74hc164n chip, so I use only 2 pin to control each one but between each shift out all led light up (very low intensity but I still can see them lighten).

Code: [Select]
int dataPin=11;
int clockPin=12;
int del = 350;



int aA = B00010001;

int aB = B00010010;

int aC = B00010100;

int aD = B00011000;

int bA = B00100001;

int bB = B00100010;

int bC = B00100100;

int bD = B00101000;

int cA = B01000001;

int cB = B01000010;

int cC = B01000100;

int cD = B01001000;

int dA = B10000001;

int dB = B10000010;

int dC = B10000100;

int dD = B10001000;



void setup(){
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}
void loop(){
shiftOut(dataPin, clockPin, LSBFIRST, aA);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, aB);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, aC);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, aD);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, bA);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, bB);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, bC);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, bD);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, cA);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, cB);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, cC);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, cD);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, dA);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, dB);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, dC);

delay(del);

shiftOut(dataPin, clockPin, LSBFIRST, dD);

delay(del);
}
Title: Re: led multiplexing
Post by: johnwasser on Nov 26, 2011, 05:52 am
I think the problem is that the shift register has no latch signal so the data being clocked through gets displayed.  Perhaps it would get better if you pulled the Clear pin low between displays.  That would clear all the data but any 1 bit you clock in will appear on each pin in turn until it reaches its final position.  If you use a latched shift register the data only appears on the outputs when you set the latch HIGH.
Title: Re: led multiplexing
Post by: Grumpy_Mike on Nov 26, 2011, 12:14 pm
See this for the basics of driving an array:-
http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html (http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html)