# Arduino Uno - Led Control - Array Problem

Hallo,

ich habe an einen Uno Rev3, um 19 LEDs zu kontrollieren, 3 74HC595 Schieberegister angeschlossen.
Folgendes Problem ist:
Das Programm läuft stabil für eine Größe der Arrays von 18. Für die eigentliche Anwendung brauch ich aber 234 Werte.

int latchPin = 8;         //Shifregister Latch
int dataPin = 11;         //Shiftregister Data
int clockPin = 12;        //Shiftregister Clock
int pushButton = 7;       //Push Button -> Start Sequence
int ledShift [234] = {128,64,32,16,8,4,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,4,
8,16,32,64,128,0,128,64,32,16,8,4,2,1,0,0,0,0,0,0,0,0,0,0,0,128,64,32,16,8,4,2,1,0,0,0,0,0,
0,0,0,0,0,128,192,160,80,40,20,10,5,2,1,0,0,0,0,0,0,0,0,128,64,32,16,8,4,2,1,0,0,0,0,0,0,0,
0,4,8,16,32,64,128,64,32,16,8,4,2,1,0,0,0,0,0,0,36,34,33,32,32,32,32,32,16,8,4,2,1,0,0,0,0,
16,0,16,8,4,2,1,0,0,0,0,24,24,88,72,72,72,72,0,0,4,2,1,0,0,0,128,64,32,16,8,4,2,1,0,0,128,64,
32,16,8,4,2,1,0,128,64,32,16,8,4,2,1,3,5,9,17,33,65,129,1,129,65,33,17,9,5,3,131,67,35,19,11,
7,15,31,127,255,127,63,31,31,15,7,3,1,0,0,0};     //Sequence LED 1-8
int ledShift2 [234] = {0,0,0,0,0,0,0,0,128,64,32,16,8,4,2,1,0,0,0,0,0,1,2,4,8,16,32,64,128,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,64,32,16,8,4,2,1,0,0,0,0,0,0,0,0,0,0,0,128,64,32,16,8,
4,2,1,0,0,0,0,0,0,0,0,0,0,128,64,160,80,40,20,10,5,2,1,1,1,1,1,1,1,1,1,1,129,65,33,17,9,5,3,3,
3,3,3,3,3,3,3,3,3,3,3,3,131,67,35,19,11,7,7,7,7,135,71,39,23,15,15,15,15,15,15,143,79,47,31,31,
29,31,31,31,31,31,159,95,63,43,43,41,41,41,45,13,31,31,31,31,31,31,159,95,63,63,63,63,63,63,63,
63,63,191,127,127,127,127,127,127,127,127,127,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,254,252,248,240,224,192,64,0};    //Sequence LED 9-16
int ledShift3 [234] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,64,32,64,128,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,64,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
160,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,224,224,224,224,224,224,224,224,224,224,224,
224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,192,128,0,0,0,0,
0,0,0,0,0};    //Sequence LED 17-19
long time [234] = {443,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,
130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,5600,400,130,130,130,130,130,130,130,
130,130,130,130,130,130,130,130,130,130,4460,400,130,130,130,130,130,130,130,130,130,130,130,130,130,130,
130,130,2719,5558,1447,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,1964,1834,130,130,130,
130,130,130,130,130,130,130,130,130,130,130,1748,1825,130,130,130,130,430,100,110,110,110,110,110,110,110,
110,110,110,110,2587,1831,130,130,130,130,130,130,258,130,130,130,130,130,130,130,130,2580,3668,3710,1835,
130,130,130,130,130,130,4478,1800,1840,640,1170,1820,750,1240,1660,1150,760,670,130,130,130,130,4800,400,
130,130,130,130,130,130,130,130,130,400,130,130,130,130,130,130,130,130,400,130,130,130,130,130,130,1440,200,
200,200,200,200,200,1240,4100,400,130,130,130,130,130,1240,400,130,130,130,130,1550,100,3662,3674,3,250,250,250,
250,250,250,250,250,250,250,5000};         //Delay between LEDs in millis
int value = 0;            //shiftout counter
int value2 = 0;
int value3 = 0;

void setup ()
{
pinMode (latchPin, OUTPUT);
pinMode (dataPin, OUTPUT);
pinMode (clockPin, OUTPUT);
pinMode (statusLed, OUTPUT);
pinMode (pushButton, INPUT);

Serial.begin (9600);
}

void loop ()
{
for (int counter=0; counter < 233; counter ++)
{
value = ledShift[counter];
value2 = ledShift2[counter];
value3 = ledShift3[counter];
writeOutput();
delay (time[counter]);
}

}

void writeOutput()                                  //Shiftregister Output
{
digitalWrite (latchPin, LOW);                      //Latch LOW -> Send Data
shiftOut (dataPin, clockPin, MSBFIRST, value3);    //Send Data To Shiftreg 3
shiftOut (dataPin, clockPin, MSBFIRST, value2);    //Send Data To Shiftreg 2
shiftOut (dataPin, clockPin, MSBFIRST, value);     //Send Data To Shiftreg 1
digitalWrite (latchPin, HIGH);                     //Latch HIGH -> Display Data
Serial.write ("Ding Dong");
}

setze ich nun für das delay in der loop einen festen Wert ein, dann läuft das Ganze, aber für den “time” Wert nicht. Dann kommt nicht mal was am Serial Monitor raus. ich versteh nicht was genau das Problem ist :~ habt ihr da ne Idee?

Auf dem UNO ist hierfür bei weitem nicht genug Speicher. Der hat nur 2kB RAM! Ein int benötigt 2 Byte. Ein long hat 4 Byte!

Du musst den Speicher optimieren. Wenn du nur Werte von 0-255 brauchst, byte statt int verwenden. Und generell für alle Arrays PROGMEM verwenden: http://arduino.cc/en/Reference/PROGMEM Dann landet das alles im Flash.

Time muss hier auch gar nicht long sein. In einen unsigned int gehen Werte bis 65535

Juhuuu :) es läuft:) danke schön:)