# 24X6 Led Matrix works BUT I want to add animations also. Need help!!

I used the 24X6 matrix from http://www.instructables.com/id/Make-a-24X6-LED-matrix/ . I wired it up exactly like they have it and I’m using this code . What I would like to do is add animations to it after scrolling some words. Example Scroll words “Hello World” then do a Cylon eye across all Led’s a few times then make a couple led’s bounce around randomly. Basically I just want it to add anything else after the scrolling words then after that animation loop back to scrolling words
Any help would be appreciated.

LOL, something complicated coding of the author, I would have taken the other side.

-- replace this:

# define PaintAll{B11111000,B11111000,B11111000,B11111000,B11111000,B11111000}

long scrolling_word[6]; int array_turn=0; byte your_text[5][6] ={PaintAll,PaintAll,PaintAll,PaintAll,PaintAll};

was painted across the screen?

ductgsxr: I have some more 74hc595's . would it better to use that chip or another chip instead of the 4017 and a different code??

sorry, bear with me, I do not speak English.

I need as the author this image encoding, so I ask if the code you send, paints the entire screen.

no need to change the hardware, it is a "problem" software

for(int p=0;p<0;p++) //chance

Here's some guidance:

You need to think of the LEDs as pixels on a display and write a function that will turn on and off one pixel. To do this you need to decide where the origin (0,0) of the matrix is and then when the function to turn on pixel (x,y) you can do a translation of what that means for your hardware (ie, you need to control something to make it happen). Once you can do that, the rest is easy. You can write functions to do vertical, horizontal, arbitrary lines, circles, etc, because all they are is points turning on and off.

Bouncing balls are a pixel turned on, wait some time, pixel off and next pixel on (in the direction of travel), wait, etc. Edge detection changes the direction of the coordinate that goes out of boundary (ie, if we were adding one we now subtract one to the coordinate).

The MD_MAX72xx library in my repository (below) implements these sorts of function in a different situation, so you may be able to see what I have done there (not beginner code though).

:astonished:. ja

Ok then, good luck with your project.

I'm not going to write the code for you, but making individual LEDs go on and off seems much easier than scrolling text, and if you can display scrolling text then you can display stationary text and if you can display stationary text you can turn individual LEDs on and off, and if you can turn individual LEDs on and off then you can make a spot seem to move from one position to the next and produce the simple animation effects you're looking for. That's how I see it anyway - you just need to dig down into your existing code and locate the logic which turns individual LEDs on and off, and you're basically sorted. Whether you're interested in doing that for yourself is up to you, of course.

Trying to get my code for a 24x6 Matix to work. It works for scrolling text but I got rid of most of the code because I don’t want scrolling words I just want to control individual led’s. Currently I can control only the top row of led’s how ever I want, but I can not figure out what I’m missing to control each of the other 5 rows. I know it’s got to be something simple. Not familiar with the 4017. need help Please.

``````int latchPin = 10;
int clockPin = 13;
int dataPin = 11;
int clock = 9;
int Reset = 8;
int latchPinPORTB = latchPin - 8;
int clockPinPORTB = clockPin - 8;
int dataPinPORTB = dataPin - 8;
int i = 0;

void setup(){
Serial.begin(9600);
pinMode(dataPin,OUTPUT);
pinMode(clockPin,OUTPUT);
pinMode(latchPin,OUTPUT);
pinMode(clock,OUTPUT);
pinMode(Reset,OUTPUT);
digitalWrite(Reset,HIGH);
digitalWrite(Reset,LOW);

}
void loop() {

for (int i=0; i <= 10; i++){
lightLeds (0b00111100, 0b00111100, 0b00111100, 0b00000000); // 1st is 3rd matrix rows 2nd is middle matrix rows 3rd is 1st matrix rows 4th is last

}

for (int i=0; i <= 10; i++){
lightLeds (0b11000011, 0b11000011, 0b11000011, 0b00000000); // 1st is 3rd matrix rows 2nd is middle matrix rows 3rd is 1st matrix rows 4th is last

}
}
void lightLeds (int forth, int third, int second, int first) {
digitalWrite (latchPin, LOW);
shiftOut (dataPin, clockPin, LSBFIRST, first);
shiftOut (dataPin, clockPin, LSBFIRST, second);
shiftOut (dataPin, clockPin, LSBFIRST, third);
shiftOut (dataPin, clockPin, LSBFIRST, forth);
digitalWrite (latchPin, HIGH);
delay (20);

}
``````

The 4017 has a counter and 10 outputs . If you pulse the Reset line the counter resets to 0 and output Q0 turns on. When you pulse the Count line the counter increments and the next output turns on.

Pulse Reset
For row =0; row < 10; row++
Set latch low
Shift out a row
Raise latch
Delay a few milliseconds
Set latch low
Shift out zeroes to tUrn off LEDs
Set latch high
Pulse clock to increment row

Looks like your hardware can support 8 rows of 24 LEDs.

Wait the latch is on the 595 so I’m confused by that.

Well I am 100% convinced that NO one has or can use the 4017 with a 595 in a LED Matrix besides scrolling words. THERE IS NOTHING on google or here or Anywhere else where someone has used the 4017 with a 595 for animations on a matrix or just controlling individual LED's with an arduino. So I guess i'll scrap this project and start using some other chip. I would be excited to be proved wrong.

I'll just keep all these related threads together will I? For our sanity's sake.

ductgsxr: Wait the latch is on the 595 so I'm confused by that.

The 74595's represent one row of 24 bits. You lower latchPin to start the loading of the row. You shift out (dataPin, clockPin) three bytes to fill the row, then you raise latchPin to display the row.

The 4017 is the row selector. You pulse Reset to switch to row 0. You pulse clock to switch to the next row.

johnwasser:

ductgsxr:
Wait the latch is on the 595 so I’m confused by that.

The 4017 is the row selector. You pulse Reset to switch to row 0. You pulse clock to switch to the next row.

Ok That help thanks. But I’m still having a hard time with the code. I do not know how to get the clock to “pulse”. I can build anything but programming is my weak area. I appreciate any help. I just can not figure out how to write it into my existing code. If I can just get a few lines of code (and where to put it) just to turn on one or two LED’s in this code below. I l know I can figure out the rest.

``````int latchPin = 10;
int clockPin = 13;
int dataPin = 11;
int clock = 9;
int Reset = 8;
int latchPinPORTB = latchPin - 8;
int clockPinPORTB = clockPin - 8;
int dataPinPORTB = dataPin - 8;
int i = 0;

void setup(){
Serial.begin(9600);
pinMode(dataPin,OUTPUT);
pinMode(clockPin,OUTPUT);
pinMode(latchPin,OUTPUT);
pinMode(clock,OUTPUT);
pinMode(Reset,OUTPUT);
digitalWrite(Reset,HIGH);
digitalWrite(Reset,LOW);

}
void loop() {

for (int i=0; i <= 10; i++){
lightLeds (0b00111100, 0b00111100, 0b00111100, 0b00000000); // 1st is 3rd matrix rows 2nd is middle matrix rows 3rd is 1st matrix rows 4th is last

}

for (int i=0; i <= 10; i++){
lightLeds (0b11000011, 0b11000011, 0b11000011, 0b00000000); // 1st is 3rd matrix rows 2nd is middle matrix rows 3rd is 1st matrix rows 4th is last

}
}
void lightLeds (int forth, int third, int second, int first) {
digitalWrite (latchPin, LOW);
shiftOut (dataPin, clockPin, LSBFIRST, first);
shiftOut (dataPin, clockPin, LSBFIRST, second);
shiftOut (dataPin, clockPin, LSBFIRST, third);
shiftOut (dataPin, clockPin, LSBFIRST, forth);
digitalWrite (latchPin, HIGH);
delay (20);

}
``````

ductgsxr:
I do not know how to get the clock to “pulse”.

``````    // Pulse the 4017 clock
digitalWrite(clock, HIGH);
digitalWrite(clock, LOW);
``````

Ahh ok I tried digitalWrite but did not use the word "clock" thank you I WILL try it out when I get off work.

Ok I’ve got it to atleast light up and move around but I still can’t choose just one or muiltiple rows. It just runs through all 10 pulse’s Which is a step and I appriciate that. I’m getting somewhere but I can’t control an individual led. Like I can control which columns come on with a simple change of etc (lightLeds (0b00100000, 0b00111100, 0b00111100); I’d love to get this code to be able to control the rows by adding a forth etc (lightLeds (0b00100000, 0b00111100, 0b00111100,0b00111100); Now I have done this plenty of times with ALL 74hc595 but not with this 4017. Is it really that much of a harder code? This is where I’m at now with the code.

``````int latchPin = 10;
int clockPin = 13;
int dataPin = 11;
int clock = 9;
int Reset = 8;
int latchPinPORTB = latchPin - 8;
int clockPinPORTB = clockPin - 8;
int dataPinPORTB = dataPin - 8;
int i = 0;

void setup(){
Serial.begin(9600);
pinMode(dataPin,OUTPUT);
pinMode(clockPin,OUTPUT);
pinMode(latchPin,OUTPUT);
pinMode(clock,OUTPUT);
pinMode(Reset,OUTPUT);
digitalWrite(Reset,HIGH);
digitalWrite(Reset,LOW);

}
void loop() {

for (int i=0; i <= 100; i++){
lightLeds (0b10000000, 0b00111100, 0b00111100); // 1st is 3rd matrix rows 2nd is middle matrix rows 3rd is 1st matrix rows 4th is last

digitalWrite(clock, HIGH);
digitalWrite(clock, LOW);
lightLeds (0b01000000, 0b00111100, 0b00111100); // 1st is 3rd matrix rows 2nd is middle matrix rows 3rd is 1st matrix rows 4th is last

digitalWrite(clock, HIGH);
digitalWrite(clock, LOW);
lightLeds (0b00100000, 0b00111100, 0b00111100); // 1st is 3rd matrix rows 2nd is middle matrix rows 3rd is 1st matrix rows 4th is last
lightLeds (0b00010000, 0b00111100, 0b00111100); // 1st is 3rd matrix rows 2nd is middle matrix rows 3rd is 1st matrix rows 4th is last
digitalWrite(clock, HIGH);
digitalWrite(clock, LOW);
}
}
void lightLeds (int third, int second, int first) {
digitalWrite (latchPin, LOW);
shiftOut (dataPin, clockPin, LSBFIRST, first);
shiftOut (dataPin, clockPin, LSBFIRST, second);
shiftOut (dataPin, clockPin, LSBFIRST, third);
digitalWrite (latchPin, HIGH);
delay (200);

}
``````

The 4017 is intergrated only to serve as the cyclone routine. Its just a counter,

Im new and green ..but within the same command line as the 4017. .it seems to me that the code to get a bouncing led would have to be sent to 74595..with in the came comand. Im setting here thinking if theres a conflict between the counter and the register's when one or the other decides to activate the same led?

If you want to use different hardware, that would be fine. If you want to use the existing hardware you need something like this:

``````const int Latch74595Pin = 10;
const int Clock74595Pin = 13;
const int Data74595Pin = 11;
const int Clock4017Pin = 9;
const int Reset4017Pin = 8;

byte Buffer[8][3];  // 8 rows of 24 columns

void ClearBuffer() {
for (int row=0; row < 8; row++) {
Buffer[row][0] = 0;
Buffer[row][1] = 0;
Buffer[row][2] = 0;
}
}

void setup() {
Serial.begin(9600);
ClearBuffer();
pinMode(Data74595Pin,OUTPUT);
pinMode(Clock74595Pin,OUTPUT);
pinMode(Latch74595Pin,OUTPUT);
digitalWrite(Latch74595Pin, HIGH);

pinMode(Clock4017Pin,OUTPUT);
digitalWrite(Clock4017Pin, LOW);
pinMode(Reset4017Pin,OUTPUT);
digitalWrite(Reset4017Pin, LOW);
}

void loop() {
static int currentRow, currentColumn;

RefreshDisplay();

TogglePixel(currentRow, currentColumn);
currentColumn++;
if (currentColumn > 23) {
currentColumn = 0;
currentRow++;
if (currentRow > 7)
currentRow = 0;
}
}

void TogglePixel( int row, int column) {
int columnByte = column / 8;  // Which of the three bytes
int columnBit = column % 8;   // Which of the bits within that byte
Buffer[row][columnByte] ^= (1 << columnBit);
}

void RefreshDisplay() {
// Pulse Reset
digitalWrite(Reset4017Pin, HIGH);
digitalWrite(Reset4017Pin, LOW);

for (int row=0; row<8; row++) {

// Shift out a row
digitalWrite(Latch74595Pin, LOW);
shiftOut (Data74595Pin, Clock74595Pin, LSBFIRST, Buffer[row][0]);
shiftOut (Data74595Pin, Clock74595Pin, LSBFIRST, Buffer[row][1]);
shiftOut (Data74595Pin, Clock74595Pin, LSBFIRST, Buffer[row][2]);
digitalWrite(Latch74595Pin, HIGH);

delay(2); // This is a trade-off between brightness and flicker

// Clear the row so it doesn't show up on the next row when we increment the 4017
digitalWrite(Latch74595Pin, LOW);
shiftOut (Data74595Pin, Clock74595Pin, LSBFIRST, 0);
shiftOut (Data74595Pin, Clock74595Pin, LSBFIRST, 0);
shiftOut (Data74595Pin, Clock74595Pin, LSBFIRST, 0);
digitalWrite(Latch74595Pin, HIGH);

// Pulse the 4017 clock to select the next row
digitalWrite(Clock4017Pin, HIGH);
digitalWrite(Clock4017Pin, LOW);
}
}
``````