Go Down

Topic: 5x5x5 led cube software? (Read 2021 times) previous topic - next topic

Arjan901

Hello,

I recently started with building a led cube with an arduino mega1280. Know i'm allmost finishes but i'm not really an expert with programming. My question is, is there any program like qube5 which i can use to make patterns just by clicking on a led and the program makes the code?

That will be very helpfull

codlink

I don't think there is software that pertains directly to your cube, but you could go through Google.  I pulled up some interesting links..

http://www.hownottoengineer.com/projects/lc.html
http://arduino.cc/forum/index.php/topic,8333.0.html
http://techboy331.github.com/Arduino-LED-Cube/
http://www.instructables.com/id/3X3-LED-Cube-Programming-tips-Arduino-based/


//LiNK

Arjan901

thnx for the reply, however i have a problem with some code.

i looked at this tutorial: http://www.instructables.com/id/3X3-LED-Cube-Programming-tips-Arduino-based/
this looks really easy to make patterns, if it works.

when i want to upload the code:
Code: [Select]
/*
Based on ledcube.c from Make: September 7, 2007 weekend podcast
http://blog.makezine.com/archive/2007/09/make_a_pocket_led_cube_we.html

Custom animation programmed by Mark Boszko, http://stationinthemetro.com
*/

#include <avr/pgmspace.h>        // allows use of PROGMEM to store patterns in flash

#define CUBESIZE 3
#define PLANESIZE CUBESIZE*CUBESIZE
#define PLANETIME 3333          // time each plane is displayed in us -> 100 Hz refresh
#define TIMECONST 5          // multiplies DisplayTime to get ms - why not =100?

// LED Pattern Table in PROGMEM - last column is display time in 100ms units
// TODO this could be a lot more compact but not with binary pattern representation
prog_uchar PROGMEM PatternTable[] = {


  B101, B010, B101, B000, B000, B000, B000, B000, B000, 50 ,
  B000, B000, B000, B000, B010, B000, B000, B000, B000, 50 ,
  B000, B000, B000, B000, B000, B000, B101, B010, B101, 50 ,
  B000, B000, B000, B000, B010, B000, B000, B000, B000, 50 ,
}

/*
** Defining pins in array makes it easier to rearrange how cube is wired
** Adjust numbers here until LEDs flash in order - L to R, T to B
** Note that analog inputs 0-5 are also digital outputs 14-19!
** Pin DigitalOut0 (serial RX) and AnalogIn5 are left open for future apps
*/

//int LEDPin[] = {16, 3, 1, 15, 4, 6, 14, 5, 7};
int LEDPin[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10};

//int PlanePin[] = {19, 18, 17};
int PlanePin[] = {13, 12, 11};

// initialization
void setup()
{
  int pin;      // loop counter
  // set up LED pins as output (active HIGH)
  for (pin=0; pin<PLANESIZE; pin++) {
    pinMode( LEDPin[pin], OUTPUT );
  }
  // set up plane pins as outputs (active LOW)
  for (pin=0; pin<CUBESIZE; pin++) {
    pinMode( PlanePin[pin], OUTPUT );
  }
}

// display pattern in table until DisplayTime is zero (then repeat)
void loop()
{
  // declare variables
  byte PatternBuf[ PLANESIZE ];      // saves current pattern from PatternTable
  int PatternIdx;
  byte DisplayTime;        // time*100ms to display pattern
  unsigned long EndTime;
  int plane;      // loop counter for cube refresh
  int patbufidx;   // indexes which byte from pattern buffer
  int ledrow;    // counts LEDs in refresh loop
  int ledcol;    // counts LEDs in refresh loop
  int ledpin;    // counts LEDs in refresh loop

  // Initialize PatternIdx to beginning of pattern table
  PatternIdx = 0;
  // loop over entries in pattern table - while DisplayTime>0
  do {
    // read pattern from PROGMEM and save in array
    memcpy_P( PatternBuf, PatternTable+PatternIdx, PLANESIZE );
    PatternIdx += PLANESIZE;
    // read DisplayTime from PROGMEM and increment index
    DisplayTime = pgm_read_byte_near( PatternTable + PatternIdx++ );   
    // compute EndTime from current time (ms) and DisplayTime
    EndTime = millis() + ((unsigned long) DisplayTime) * TIMECONST;

    // loop while DisplayTime>0 and current time < EndTime
    while ( millis() < EndTime ) {
      patbufidx = 0;    // reset index counter to beginning of buffer
      // loop over planes
      for (plane=0; plane<CUBESIZE; plane++) {
        // turn previous plane off
        if (plane==0) {
          digitalWrite( PlanePin[CUBESIZE-1], LOW );
        } else {
          digitalWrite( PlanePin[plane-1], LOW );
        }

        // load current plane pattern data into ports
        ledpin = 0;
        for (ledrow=0; ledrow<CUBESIZE; ledrow++) {
          for (ledcol=0; ledcol<CUBESIZE; ledcol++) {
            digitalWrite( LEDPin[ledpin++], PatternBuf[patbufidx] & (1 << ledcol) );
          }
          patbufidx++;
        }

        // turn current plane on
        digitalWrite( PlanePin[plane], HIGH );
        // delay PLANETIME us
        delayMicroseconds( PLANETIME );
      }    // for plane
    }    // while <EndTime
  } while (DisplayTime > 0);        // read patterns until time=0 which signals end
}



then i get this errors:
Code: [Select]
sketch_jan07a:34: error: expected ',' or ';' before 'int'
sketch_jan07a.ino: In function 'void setup()':
sketch_jan07a:45: error: 'LEDPin' was not declared in this scope
sketch_jan07a.ino: In function 'void loop()':
sketch_jan07a:95: error: 'LEDPin' was not declared in this scope


what can be the problem?

tuxduino

You just forgot a ;

Code: [Select]
prog_uchar PROGMEM PatternTable[] = {
  B101, B010, B101, B000, B000, B000, B000, B000, B000, 50 ,
  B000, B000, B000, B000, B010, B000, B000, B000, B000, 50 ,
  B000, B000, B000, B000, B000, B000, B101, B010, B101, 50 ,
  B000, B000, B000, B000, B010, B000, B000, B000, B000, 50 ,
};


It's after the closing curly bracket.

Hippynerd

I've seen programs for programming 4x4x4 cubes, none of the ones I tried worked for me, but I have seen them, and I assume they worked for someone.

Heres a thread about 5x5x5, they used shift registers, and they made a windows based program to program the cube.
http://arduino.cc/forum/index.php/topic,22365.0.html

What program you use to run the cube depends on how you built your cube, and how you make data for your program depends on how your program works, so you kind of need to know how your cube works, to know how to program your cube, and to write a program to program the patterns.

I worked on 4x4x4 cube, and you could use that program. I have a version where it uses parallel data to the 16 columns, and one that uses shift registers to serialize the data.
https://sites.google.com/site/rgbledcubes

Go Up