Pages: [1]   Go Down
Author Topic: led multiplexing  (Read 687 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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);
}
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8084
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 509
Posts: 31472
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

See this for the basics of driving an array:-
http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html
Logged

Pages: [1]   Go Up
Jump to: