Hi,
about three weeks ago I bought me an arduino to play around. I had no pogramming skills at all, so it's quite an effort to teach myself the simplest things, but it's fun :).
But now I'm stuck. I soldered a little 4x4 LED matrix. (never soldered before, worked at first try yeah) Directly driven I had no problems figuring out how to light it up and display some animations. Now I plugged a 74hc595n shift register between. Shouldn't have done it.....
After hours and hours researching I managed to play simple animations like that:
//animation for 4x4 LED matrix using 74hc595n shift register.
//shows diagonal lines for every half second.
int latchPin = 8;
int clockPin = 12;
int dataPin = 11;
// diagonal line from top left to bottom right.
int diaglr[] = {  //first 4 bits are columns (anodes, HIGH/1 activates). last 4 bits are rows (cathodes, LOW/0 activates).
 B10000111,
 B01001011,
 B00101101,
 B00011110
};
// diagonal line from bottom left to top right.
int diagrl[] = {
 B00010111,
 B00101011,
 B01001101,
 B10001110
};
void setup() {
 pinMode(latchPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 pinMode(dataPin, OUTPUT);
}
void loop() {
Â
 unsigned long start1 = millis();
 while (millis() - start1 <= 500){
  for (int i = 0; i < 4; i++){
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, diaglr[i]);Â
   digitalWrite(latchPin, HIGH);
  }
 }
Â
 unsigned long start2 = millis();
Â
 while (millis() - start2 <= 500){
 for (int i = 0; i < 4; i++){
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, diagrl[i]);Â
   digitalWrite(latchPin, HIGH);
  }
 }
}
Or some other steady "images", who alternate. Now i want to make a snake-like animation: snake starts in the top left corner, goes to top right, bottom right, bottom left, up, and then in a spiral to the middle. At the end the LEDs should all be on and it should start again. I found the "Arduino Frame Animator" here in the forum. Unfortunately I don't know how to parse it in my code. I tried, but miserably failed... I used two for-loops like I did, when I directly drove the matrix:
//just a snippet. Imagine some setup and loop stuff like above...
int snake[16][4] = {
 { 0x3, 0x0, 0x0, 0x0 },
 { 0xf, 0x0, 0x0, 0x0 },
 { 0x3f, 0x0, 0x0, 0x0 },
 { 0xff, 0x0, 0x0, 0x0 },
 { 0xff, 0xc0, 0x0, 0x0 },
 { 0xff, 0xc0, 0xc0, 0x0 },
 { 0xff, 0xc0, 0xc0, 0xc0 },
 { 0xff, 0xc0, 0xc0, 0xf0 },
 { 0xff, 0xc0, 0xc0, 0xfc },
 { 0xff, 0xc0, 0xc0, 0xff },
 { 0xff, 0xc0, 0xc3, 0xff },
 { 0xff, 0xc3, 0xc3, 0xff },
 { 0xff, 0xcf, 0xc3, 0xff },
 { 0xff, 0xff, 0xc3, 0xff },
 { 0xff, 0xff, 0xf3, 0xff },
 { 0xff, 0xff, 0xff, 0xff }
};
void loop(){
  for (int i = 0; i < 16; i++){  Â
   for (int j = 0; j < 4; j++){
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, snake[i][j]);Â
   digitalWrite(latchPin, HIGH);
   delay(250);
  }
  delay(250);
 }
}
But it just blinks randomly. Due to my very poor coding skills, I have no clue how to do it. Can you help me?
samsa
edit: I looked at the example provided by the maker of the animation creator. But there's just too much stuff I don't understand or (at the moment) don't need (like PWM)....