Hi
I have been building an 8 by 8 Matrix of RGB LEDS using common cathode bulbs and 74HC595 shift registers.
I am posting my schematic below and asking is it going to be possible to individually address each led in this matrix as well as enable Pulse Width Modulation (PWM) ? And if it is possible can anyone point me in the right direction?
As it stands now it is all soldered together and I can cycle through the rows that are each assigned to a pin on the 74HC595 but I can't figure out how to cycle through the columns or enable PWM.
I am using one shift register for each of the red, green, and blue anodes and then one shift register for the cathodes via 8 BC548 transistors.
I have been searching online for examples of RGB matrix using PWM but it is all common anode. Any clues would be greatly appreciated.
Here is a preview image and below is a link to download the pdf of the whole matrix.
Here is a photo of the prototype so far. If I can't use PWM with this design then I clearly left the breadboard stage to early.
Here is the code that lets me display solid colors and cycle through rows:
int latchPin = 8; // connect to pin 12 on the '595
int clockPin = 10; // connect to pin 11 on the '595
int dataPin = 9; // connect to pin 14 on the '595
byte data = 0;
int va[]={
1,2,4,8,16,32,64,128,255};
void setup() {
pinMode(latchPin, OUTPUT);
}
void loop() {
rowMix();
blinkAll_2Bytes(3,500);
}
void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
int i=0;
int pinState;
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, OUTPUT);
digitalWrite(myDataPin, 0);
digitalWrite(myClockPin, 0);
for (i=7; i>=0; i--) {
digitalWrite(myClockPin, 0);
if ( myDataOut & (1<<i) ) {
pinState= 1;
}
else {
pinState= 0;
}
digitalWrite(myDataPin, pinState);
digitalWrite(myClockPin, 1);
digitalWrite(myDataPin, 0);
}
digitalWrite(myClockPin, 0);
}
void blinkAll_2Bytes(int n, int d) {
//digitalWrite(latchPin, 0);
//shiftOut(dataPin, clockPin, 255);
//shiftOut(dataPin, clockPin, 255);
//shiftOut(dataPin, clockPin, 255);
//digitalWrite(latchPin, 1);
//delay(500);
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, 255);
shiftOut(dataPin, clockPin, 255);
shiftOut(dataPin, clockPin, 0);
shiftOut(dataPin, clockPin, 0);
digitalWrite(latchPin, 1);
delay(500);
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, 255);
shiftOut(dataPin, clockPin, 0);
shiftOut(dataPin, clockPin, 255);
shiftOut(dataPin, clockPin, 0);
digitalWrite(latchPin, 1);
delay(500);
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, 255);
shiftOut(dataPin, clockPin, 0);
shiftOut(dataPin, clockPin, 0);
shiftOut(dataPin, clockPin, 255);
digitalWrite(latchPin, 1);
delay(500);
}
void rowMix()
// warning! warning! blinkiness ahead!
{
for (int z=0; z<30; z++)
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, va[random(8)]); // cathodes
shiftOut(dataPin, clockPin, MSBFIRST, va[random(8)]); // green
shiftOut(dataPin, clockPin, MSBFIRST, va[random(8)]); // blue
shiftOut(dataPin, clockPin, MSBFIRST, va[random(8)]); // red
digitalWrite(latchPin, HIGH);
delay(100);
}
}