please help with code

#include <avr/pgmspace.h>

#define COLUMN 8 // Anzahl der Spalten
#define PLANE 5 // Anzahl der Ebenen
#define PLANETIME 3333 // Anzeigedauer einer Ebene
#define TIMECONST 15 // Multiplikator für Anzeigedauer eines Bildes (33 LEDs)

// LED Muster: Eine Zeile besteht aus den 5 Ebenen mit je 8 LEDs (außer Ebene 5 mit einer LED) und der Anzeigedauer
prog_uchar PROGMEM PatternTable[] = {
B11111111, B11111111, B11111111, B11111111, B1, 5, // Alle LEDs an
B00000000, B00000000, B00000000, B00000000, B0, 1, // Alle LEDs aus
B11111111, B11111111, B11111111, B11111111, B1, 5,
B00000000, B00000000, B00000000, B00000000, B0, 10,
// Bei Anzeigedauer 0 endet die Schleife
B00000000, B00000000, B00000000, B00000000, B0, 0
};

// Definition der Pins für Ebenen und Spalten (hängt davon ab, wie man sie verlötet hat)
int LedPin[] = {7, 8, 6, 9, 10, 11, 12, 5};
int PlanePin[] = {18, 17, 16, 15, 14};

void setup()
{
int pin;
// Pins als OUTPUT initialiseren
for (pin=0; pin<COLUMN; pin++) {
pinMode( LedPin[pin], OUTPUT );
}

for (pin=0; pin<PLANE; pin++) {
pinMode( PlanePin[pin], OUTPUT );
}
}

void loop()
{
byte PatternBuf[PLANE]; // speichert eine Zeile aus LED Muster
int PatternIdx;
byte DisplayTime;
unsigned long EndTime;
int plane;
int patbufidx;
int ledpin;

// Index in LED Muster setzen
PatternIdx = 0;
// Wiederholen solange Anzeigedauer > 0
do {
// Zeile aus LED Muster lesen
memcpy_P( PatternBuf, PatternTable+PatternIdx, PLANE );
PatternIdx += PLANE;
// Anzeigedauer lesen
DisplayTime = pgm_read_byte_near( PatternTable + PatternIdx++ );
// Anzeigedauer für Bild berechnen
EndTime = millis() + ((unsigned long) DisplayTime) * TIMECONST;

// LEDs der Ebenen immer wieder aufbauen, solange Anzeigedauer für Bild noch nicht erreicht ist
while ( millis() < EndTime ) {
patbufidx = 0; // Am Anfang der Zeile beginnen
// Schleife über Ebenen
for (plane=0; plane<PLANE; plane++) {
// vorherige Ebene ausschalten
if (plane==0) {
digitalWrite( PlanePin[PLANE-1], HIGH );
} else {
digitalWrite( PlanePin[plane-1], HIGH );
}

// Spalten der aktuelle Ebene setzen

// Ebene 5 gesondert behandeln, da nur eine LED
if (plane==PLANE-1) {
digitalWrite( LedPin[0], PatternBuf[plane] );
} else {
// Einzelne Spalten setzen
for (ledpin=0; ledpin<COLUMN; ledpin++) {
// Bitoperation zur Ermittlung der einzelnen Bitwerte
// Beispiel:
// LED Zeile & ledpin (left shift (<<) schiebt ledpin um 1 nach rechts)
// B01010000 & B10000000 = 0 (LED leuchtet nicht)
// B01010000 & B01000000 = 1 (LED leuchtet)
// B01010000 & B00100000 = 0 (LED leuchtet nicht)
digitalWrite( LedPin[ledpin], PatternBuf[plane] & (1 << ledpin) );
}
}

// aktuelle Ebene aktivieren
digitalWrite( PlanePin[plane], LOW );
// Anzeigedauer für Ebene
delayMicroseconds( PLANETIME );
}
}
} while (DisplayTime > 0);
}

i uploaded the file to the atmega328 arduinoBoardDuemilanove and all it does it keeps blinking on off.please help.

Please modify your post, select the code and press the # button so the code get tagged properly,
thank you

i uploaded the file to the atmega328 arduinoBoardDuemilanove and all it does it keeps blinking on off.please help.

You uploaded code to blink LEDs, and all the LEDs do is blink. And the problem is?

What do you expect this code to do? What does it actually do?

#include <avr/pgmspace.h>

#define COLUMN 8        // Anzahl der Spalten
#define PLANE 5         // Anzahl der Ebenen
#define PLANETIME 3333  // Anzeigedauer einer Ebene
#define TIMECONST 15    // Multiplikator für Anzeigedauer eines Bildes (33 LEDs)

// LED Muster: Eine Zeile besteht aus den 5 Ebenen mit je 8 LEDs (außer Ebene 5 mit einer LED) und der Anzeigedauer
prog_uchar PROGMEM PatternTable[] = {
B11111111, B11111111, B11111111, B11111111, B1, 5,  // Alle LEDs an
B00000000, B00000000, B00000000, B00000000, B0, 1,  // Alle LEDs aus
B11111111, B11111111, B11111111, B11111111, B1, 5,
B00000000, B00000000, B00000000, B00000000, B0, 10,
// Bei Anzeigedauer 0 endet die Schleife
B00000000, B00000000, B00000000, B00000000, B0, 0
};

// Definition der Pins für Ebenen und Spalten (hängt davon ab, wie man sie verlötet hat)
int LedPin[] = {7, 8, 6, 9, 10, 11, 12, 5};
int PlanePin[] = {18, 17, 16, 15, 14};

void setup()
{
	int pin;
	// Pins als OUTPUT initialiseren
	for (pin=0; pin<COLUMN; pin++) {
		pinMode( LedPin[pin], OUTPUT );
	}

	for (pin=0; pin<PLANE; pin++) {
		pinMode( PlanePin[pin], OUTPUT );
	}
}

void loop()
{
	byte PatternBuf[PLANE]; // speichert eine Zeile aus LED Muster
	int PatternIdx;
	byte DisplayTime;
	unsigned long EndTime;
	int plane;
	int patbufidx;
	int ledpin;
	
	// Index in LED Muster setzen
	PatternIdx = 0;
	// Wiederholen solange Anzeigedauer > 0
	do {
		// Zeile aus LED Muster lesen
		memcpy_P( PatternBuf, PatternTable+PatternIdx, PLANE );
		PatternIdx += PLANE;
		// Anzeigedauer lesen
		DisplayTime = pgm_read_byte_near( PatternTable + PatternIdx++ ); 
		// Anzeigedauer für Bild berechnen
		EndTime = millis() + ((unsigned long) DisplayTime) * TIMECONST;
		
		// LEDs der Ebenen immer wieder aufbauen, solange Anzeigedauer für Bild noch nicht erreicht ist
		while ( millis() < EndTime ) {
			patbufidx = 0; // Am Anfang der Zeile beginnen
			// Schleife über Ebenen
			for (plane=0; plane<PLANE; plane++) {
				// vorherige Ebene ausschalten
				if (plane==0) {
				  digitalWrite( PlanePin[PLANE-1], HIGH );
				} else {
				  digitalWrite( PlanePin[plane-1], HIGH );
				}
		
				// Spalten der aktuelle Ebene setzen

				// Ebene 5 gesondert behandeln, da nur eine LED
 				if (plane==PLANE-1) {
				    digitalWrite( LedPin[0], PatternBuf[plane] );
                                } else {
				    // Einzelne Spalten setzen
                                   for (ledpin=0; ledpin<COLUMN; ledpin++) {
				      // Bitoperation zur Ermittlung der einzelnen Bitwerte
				      // Beispiel:
				      // LED Zeile & ledpin (left shift (<<) schiebt ledpin um 1 nach rechts)
				      // B01010000 & B10000000 = 0 (LED leuchtet nicht)
				      // B01010000 & B01000000 = 1 (LED leuchtet)
				      // B01010000 & B00100000 = 0 (LED leuchtet nicht)
 				      digitalWrite( LedPin[ledpin], PatternBuf[plane] & (1 << ledpin) );
				    } 
                                }
		
				// aktuelle Ebene aktivieren
				digitalWrite( PlanePin[plane], LOW );
				// Anzeigedauer für Ebene
				delayMicroseconds( PLANETIME );
			}
		}
	} while (DisplayTime > 0);
}

this is basically a led tree with 5 plane and 8 columns..this is supposed to have diff effects..please have a look at this http://m12s23.vlinux.de/mediawiki/index.php/Xmastree

this is basically a led tree with 5 plane and 8 columns..this is supposed to have diff effects.

OK. So what do you expect the code to do? What does is ACTUALLY do? How does what it actually does differ from what you want?

follow the link and this is what its supposed to do.all it does is blink the leds on and off after i uploaded the file to the arduino board.

all it does is blink the leds on and off after i uploaded the file to the arduino board.

prog_uchar PROGMEM PatternTable[] = {
B11111111, B11111111, B11111111, B11111111, B1, 5,  // Alle LEDs an
B00000000, B00000000, B00000000, B00000000, B0, 1,  // Alle LEDs aus
B11111111, B11111111, B11111111, B11111111, B1, 5,
B00000000, B00000000, B00000000, B00000000, B0, 10,
// Bei Anzeigedauer 0 endet die Schleife
B00000000, B00000000, B00000000, B00000000, B0, 0
};

All you have defined for the patterns is either all on or all off. I don't know how/why you expect to see different patterns.

robtillaart:
Please modify your post, select the code and press the # button so the code get tagged properly,
thank you

please help as i am struggling with this for a month now..

PaulS:

all it does is blink the leds on and off after i uploaded the file to the arduino board.

prog_uchar PROGMEM PatternTable[] = {

B11111111, B11111111, B11111111, B11111111, B1, 5,  // Alle LEDs an
B00000000, B00000000, B00000000, B00000000, B0, 1,  // Alle LEDs aus
B11111111, B11111111, B11111111, B11111111, B1, 5,
B00000000, B00000000, B00000000, B00000000, B0, 10,
// Bei Anzeigedauer 0 endet die Schleife
B00000000, B00000000, B00000000, B00000000, B0, 0
};



All you have defined for the patterns is either all on or all off. I don't know how/why you expect to see different patterns.

if you look at the code after this it does different patterns i suppose..

No it does not. There are only 5 sequences and they are on, off, on, off, off. I don't think you understand the code that well. The following section dictates how the tree is lit:

prog_uchar PROGMEM PatternTable[] = {
B11111111, B11111111, B11111111, B11111111, B1, 5,  // Alle LEDs an
B00000000, B00000000, B00000000, B00000000, B0, 1,  // Alle LEDs aus
B11111111, B11111111, B11111111, B11111111, B1, 5,
B00000000, B00000000, B00000000, B00000000, B0, 10,
// Bei Anzeigedauer 0 endet die Schleife
B00000000, B00000000, B00000000, B00000000, B0, 0
};

Again on, off, on, off, off. If you want the tree lit differently, modify the above to different stuff.

I google translated the instruction:

"LED Muster: Eine Zeile besteht aus den 5 Ebenen mit je 8 LEDs (außer Ebene 5 mit einer LED) und der Anzeigedauer"

LED pattern: A line consists of five levels, each with 8 LEDs (except level 5 with an LED) and the display time

The first 4 numbers control the bottom 4 lever, the 5th number controls the one LED on the top, the 6th number is time this pattern is lit.

To indicate the end of loop, set 0 to time:

"Bei Anzeigedauer 0 endet die Schleife"

At display time 0 ends the loop

So change the first 4 lines of the PROGMEM code and you will see different patterns. Add more if you want but don't remove the last line of the PROGMEM code.

liudr:
No it does not. There are only 5 sequences and they are on, off, on, off, off. I don't think you understand the code that well. The following section dictates how the tree is lit:

prog_uchar PROGMEM PatternTable[] = {

B11111111, B11111111, B11111111, B11111111, B1, 5,  // Alle LEDs an
B00000000, B00000000, B00000000, B00000000, B0, 1,  // Alle LEDs aus
B11111111, B11111111, B11111111, B11111111, B1, 5,
B00000000, B00000000, B00000000, B00000000, B0, 10,
// Bei Anzeigedauer 0 endet die Schleife
B00000000, B00000000, B00000000, B00000000, B0, 0
};




Again on, off, on, off, off. If you want the tree lit differently, modify the above to different stuff.

I google translated the instruction:

"LED Muster: Eine Zeile besteht aus den 5 Ebenen mit je 8 LEDs (außer Ebene 5 mit einer LED) und der Anzeigedauer"

LED pattern: A line consists of five levels, each with 8 LEDs (except level 5 with an LED) and the display time

The first 4 numbers control the bottom 4 lever, the 5th number controls the one LED on the top, the 6th number is time this pattern is lit.

To indicate the end of loop, set 0 to time:

"Bei Anzeigedauer 0 endet die Schleife"

At display time 0 ends the loop

So change the first 4 lines of the PROGMEM code and you will see different patterns. Add more if you want but don't remove the last line of the PROGMEM code.

after this there is a void set up and void loop..what is this for..

after this there is a void set up and void loop..what is this for..

To set-up the I/O pins and run the sequence.

AWOL:

after this there is a void set up and void loop..what is this for..

To set-up the I/O pins and run the sequence.

so basically that does not do anythn like it shows in the video.how do i make different patterns any idea.i dont know much about programming..

You need to change the ones and zeros in "PatternTable", but don't change anything in the very last entry in the table.
Try:

prog_uchar PROGMEM PatternTable[] = {
0x55, 0xAA, 0x55, 0xAA, 1, 5, 
0x33, 0xCC, 0x33, 0x33, 0, 1,  
0x81, 0x7E, 0x81, 0x7E, 1, 5,
0xAA, 0x55, 0xAA, 0x55, 0, 10,
// 
0, 0, 0, 0, 0, 0   // don't change this
};

AWOL:
You need to change the ones and zeros in "PatternTable", but don't change anything in the very last entry in the table.
Try:

prog_uchar PROGMEM PatternTable[] = {

0x55, 0xAA, 0x55, 0xAA, 1, 5,
0x33, 0xCC, 0x33, 0x33, 0, 1, 
0x81, 0x7E, 0x81, 0x7E, 1, 5,
0xAA, 0x55, 0xAA, 0x55, 0, 10,
//
0, 0, 0, 0, 0, 0   // don't change this
};

will try it sir thank you so much.. :).if i want to add more how must i continue..

I really don't know - I simply made it up!
just try different values - theones in the original post were written in binary, mine were written in hex, which is easier for me to read.

OK, my guess was correct you don't know how the program works or how to write a program for an arduino. If you know a bit of music, I hope you understand the analogy below:

Each line is like a line of notes now you have four such lines. To play a longer sequence, mimic what is already there, add more lines and experiment with it. The setup and loop are the "piano" that plays the notes so don't pick it apart. You're not a piano repairman. As a composer, you work on the sequence only.