Modded (code) Bliptronics LED Array

So here is my Bliptronics array - I got them in last week. I’ve made two routines with a toggle button between them. I plan to add more soon. It also has a “Pulse” (dimmer) function seen on the Random routine. Here is my code and a youtube video. I’ve been out of programming for a while so if there is something I can do to improve the code let me know.

(I dont know if I’m putting the video in correctly so I’m also placing a link)

And the code (Bliptronics driving code omitted for length:

//Copyright 2010, Bryan Vandenheuvel. Section label "*** FACTORY LED Code Below***", copyright Ben Moyes.

//Ben Moyes 2010
//Use this as you wish, but please give credit, or at least buy some of my LEDs!
// Choose which 2 pins you will use for output.
// Can be any valid output pins.

#include <TimerOne.h>

// User config.
int clockPin = 12;  //GREEN wire
int dataPin = 11;   //YELLOW wire
int NoOfLEDs = 25;  //Total number of LEDs in your string.

// Globals used by interrupt code.
char  SendMode=0;   // Used in interrupt 0=start,1=header,2=data,3=data done
char  BitCount=0;   // Used in interrupt
char  LedIndex=0;   // Used in interrupt - Which LED we are sending.
char  BlankCounter=0;  //Used in interrupt.
unsigned int BitMask;   //Used in interrupt.

//Display Loop Toggle Button
const int  buttonPin = 2;
int buttonPushCounter = 0;   // counter for the number of button presses

//Display[] array holds the 15 bit RGB values for each LED.
//You'll need one for each LED, we're using 25 LEDs here.
//Note you've only got limited memory, so you can only control 
//Several hundred LEDs on a normal arduino. Double that on a Duemilanove.
int Display[25];

void setup()
  byte Counter;

  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(buttonPin, INPUT);

  // Turn all LEDs off so we don't start with a load of garbage values displayed on the LEDs
    setRange(0,24,Color(0,0,0));  //Set ALL our LEDs to black.
    Timer1.initialize(25);              // initialize timer1, 25 microseconds refresh rate.
                                        // Adjust as you please. Too slow makes LEDs flicker.
                                        // Too fast and the interrupt may chew into your processing speed!
    Timer1.attachInterrupt( LedOut ) ;  // attaches routine to drive LEDs
    show();                             // Kick off display.
    attachInterrupt(0, ButtonCheck, RISING);//Display Loop Toggle Button

void loop()
  int Counter;  //General purpose conuter for our demo loops.
  //An example sequence to diplay some patterns on LEDs arranged in a grid

  //Example 1 set a range of LEDs. Specify the start LED, end LED and give it a color value.
  //Note each value for R,G,B supplied to the Color function is in the range 0 to 31.
  //setRange(0,24,Color(31,31,31));  //Set ALL our LEDs to black.
  //show();                       //Send command out EDs
  //delay(100);                   //Wait 1/2  a sec.
  if (buttonPushCounter == 0)
    //Rainbow Box
    for(Counter=0;Counter < 16;Counter++)  //Make a rainbow
      box(0,0,4,4,Wheel(Counter * 8));  //Draw a big white box

      box(1,1,3,3,Wheel((Counter - 1) * 8));  //Draw one inside it

      setLEDFast(Translate(2,2),Wheel((Counter - 2) * 8));
    // End Rainbow
  if (buttonPushCounter == 1)
    //Random Box/Color
    setRange(0,24,Color(31,31,31));  //Set ALL our LEDs to white.
    show();                       //Send command out EDs
    delay(1000);                   //Wait a sec.
    while (1 == 1)//infinate loop
      if (buttonPushCounter != 1){break;}//exit loop if button has toggled
      int RndmPos;
      byte Rndm[3]; //random color for rgb
      RndmPos = random(0,24);
      Rndm[0] = random(0,31);
      Rndm[1] = random(0,31);
      Rndm[2] = random(0,31);
      setLEDFast(RndmPos, Rndm[0], Rndm[1], Rndm[2]);
    //end Random Color


//Pulse allows for the entire board to dim. Will need to adjust array sized based on LED array sized.
//Dly determins how long the display is dimmed so it can also be used for a long period of time.
void Pulse(int Dly)
  int DisplayPulse[25]; //used to backup the Display array for pulsing the LEDS
  for (int cnt1=0;cnt1 < 24;cnt1++)//backup the color values
    DisplayPulse[cnt1] = Display[cnt1];
  for (int cnt2=0;cnt2 < 24;cnt2++)//set color to half value
    setLEDFast(cnt2, Color((DisplayPulse[cnt2] & 15), ((DisplayPulse[cnt2] >> 10) & 15), ((DisplayPulse[cnt2] >> 5) & 15)));
    for (int cnt3=0;cnt3 < 24;cnt3++)//sets color back to original
    Display[cnt3] = DisplayPulse[cnt3];

//Button Display Loop state check
void ButtonCheck()

   //Reset the loop counter, set the value to how many loops you have.
   if (buttonPushCounter > 2) {buttonPushCounter = 0;}

//*** FACTORY LED Code Below***

Thanks for posting your project and code updates.

Curious: Is your wired from (looking at the back) .. starting on the upper left, going down and then snaking to the right?


Looking from the back: (one based for human consuption) 1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 5 10 15 20 25

Is that how your matrix is layed out?

To answer that, yes and now. I just popped them in in a zig-zag but since it's a cube I can also rotate it if the pattern goes the wrong dirrection. I haven't thought it out farther than that to be honest.

The way you have it wired will work fine as you can define any pattern layout you like. Just wanted to know the pattern layout in case I am able to put together something you can run out of the box (no pun intended).

Have fun with your matrix :)

I'm waiting for mine ... I was thinking to add a button to switch between different routines, and you did it. Good job :D:D

I received my leds ... tested your code .... awesome ;D