Close
0%
0%

Glediator from sdcard (arduino)

Glediator is a really powerful tool for controlling a led strip matrix but what about using just a microcontroller?

Similar projects worth following
This is a simple description on how I modified my old LED paintings that I made back in 2012 to run Glediator - on just an atmega 328p. No Raspberry PI or similar to run java...

Back in 2012 I built a couple of LED paintings for the kids by gluing a number of cut strips of ws2801 from eBay to a piece of cardboard that I mounted in a picture frame. Colours has a calming effect on autistic children, and if you also have ADHD it can really help you to calm down - hence why I have a few of these painting hanging around the house and my kids love them!

Solder the interconnecting wires before gluing the strips down.

One of them I also added a piece of paper behind a canvas in order to make it diffuse, and both variants are interesting in their own ways.

I quickly wrote my own proprietary protocol to make animations and such, and I spent quite a lot of time doing this - which is fun - but when I wanted to make more and more complex effects it quickly got out of hands and I eventually decided enough is enough and they went up on the walls.

They have both run since then without crashing or having any hardware failures, so the WS2812b LEDs are pretty good!

Last month I saw the Glediator project by the guys in http://www.solderlab.de/ and I thought I'd make an upgrade for my now quite old LED paintings, so after downloading their java applet and writing a sketch for an Arduino UNO they started talking with each other - and it looked fabulous, although my paintings only consists of 10x8 WS2812b LEDs...

I don't want to add a Raspberry PI to each paintings and I certainly don't want to add WiFi or similar so I decided to save the effect stream to file and just replay the recorded data in the sketch instead but after a Google session I found no implementations on the web so I had to do it myself - which is more fun to be honest ;)

Here is how you can do this yourselves:

Pick your favourite Arduino, it won't matter which you're using. You also need a sd card. (either via shield or jury-rigged to GPIO)

Download Glediator from http://www.solderlab.de/ and install. Configure Glediator with the size of your display and go wild and make some cool animations.

When you have something you like then go to Extras -> Recorder and record your animation to file, and then transfer the file(s) to the sd card you intend to use in the project.

The Arduino code is simple and can easily be extended to add a button that switches files etc.

// Glediator Arduino UNO sketch by Jens Andrée
// 500k bauds with 80 pixels no problem
// sdcard stream for stand-alone operation.

#include <FastLED.h>
#include <SPI.h>
#include <SD.h>

#define NUM_LEDS 80
#define DATA_PIN 2
#define CLOCK_PIN 3
#define CMD_NEW_DATA 1
#define BAUD_RATE 500000  //if using Glediator via serial

File fxdata;
CRGB leds[NUM_LEDS];

void setup()
{
  FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); //se doc for different LED strips
//  Serial.begin(BAUD_RATE); // when using Glediator via usb
  Serial.begin(115200);
  
  for(int y = 0 ; y < NUM_LEDS ; y++) 
  {
    leds[y] = CRGB::Black; // set all leds to black during setup
  }
  FastLED.show();

  pinMode(10, OUTPUT); // CS/SS pin as output for SD library to work.
  digitalWrite(10, HIGH); // workaround for sdcard failed error...

  if (!SD.begin(4))
  {
    Serial.println("sdcard initialization failed!");
    return;
  }
  Serial.println("sdcard initialization done.");
  
  // test file open
  fxdata = SD.open("myanim.dat");  // read only
  if (fxdata)
  {
    Serial.println("file open ok");      
    fxdata.close();
  }
}

int serialGlediator ()
{
  while (!Serial.available()) {}
  return Serial.read();
}

void loop()
{

// uncomment for Glediator  
//  while (fileGlediator () != CMD_NEW_DATA) {}
//  Serial.readBytes((char*)leds, NUM_LEDS*3);

  fxdata = SD.open("myanim.dat");  // read only
  if (fxdata)
    {
      Serial.println("file open ok");      
    }

  while (fxdata.available()) 
  {
    fxdata.readBytes((char*)leds, NUM_LEDS*3);
    FastLED.show();
    delay(50); // set the speed of the animation. 20 is appx ~ 500k bauds
  }
  
  // close the file in order to prevent hanging IO or similar throughout time
  fxdata.close();
}

And Bob's your uncle!

Here is a potato-cam of the diffused painting...

Read more »

  • 1 × Arduino UNO (or whatever your favourite is)
  • 1 × SD card reader + SD card You can wither use a Shield with SD card reader, a BYB or cobble together your own. It's easy!
  • 1 × LED strip display You can use WS2801 strips or similar to make your display and whatever size you wish to have
  • 1 × +5v power supply I save all old mobile phone chargers and reuse them to all my microcotroller projects.

  • 1

    (See Details for full desciption)

View all instructions

Enjoy this project?

Share

Discussions

kosm9252 wrote 07/23/2016 at 01:40 point

How do i get this sketch to run a LED configuration like HS-TL? No matter what mode i record in Gladiator V.2 the sketch will run the LED lights in an HL-TL configuration. Please help, i don't wanna rewire my lights in a HL configuration if i don't have to. Thanks.

  Are you sure? yes | no

kosm9252 wrote 07/23/2016 at 01:56 point

to clarify, i want to run my lights like RL-LR, but this sketch will only render the lights correctly RL-RL. Im trying to reduce the amount of wire used. an RL-LR configuration is optimal. What would i have to change in the sketch to make this work in a RL-LR light setup?

  Are you sure? yes | no

lukicharms0069 wrote 06/25/2016 at 17:44 point

I'm new to this thread and I'm attempting to make a circular display with WS2812B LED strips and SD control. I've been successful in running the animations on a regular 5x5 matrix, but I'm struggling to make an irregular shape matrix.

here is the code i have and the header file below:

// RGB Shades data output to LEDs is on pin 5
#define LED_PIN  6

// RGB Shades color order (Green/Red/Blue)
#define COLOR_ORDER GRB
#define CHIPSET     WS2812B

// Global maximum brightness value, maximum 255
#define MAXBRIGHTNESS 20
#define STARTBRIGHTNESS 102
// Include FastLED library and other useful files
#include <FastLED.h>
#include  <SPI.h>
#include <SD.h>

#include "XYmap.h"

File fxdata;

// Runs one time at the start of the program (power up or reset)
void setup() {

  Serial.begin(9600);
  SD.begin(4);

  // write FastLED configuration data
  FastLED.addLeds <CHIPSET, LED_PIN, COLOR_ORDER>(leds, LAST_VISIBLE_LED + 1);

      for(int y = 0 ; y < NUM_LEDS ; y++) 
          {
            leds[y] = CRGB::Black; // set all leds to black during setup
          }
          FastLED.show();

    // test file open
  fxdata = SD.open("myanim.dat");  // read only
  if (fxdata)
      {
        Serial.println("file open ok");      
        fxdata.close();
      }
  // set global brightness value
  FastLED.setBrightness(  MAXBRIGHTNESS );
}


// Runs over and over until power off or reset
void loop()
{
    fxdata = SD.open("myanim.dat");  // read only
while(fxdata.available())
     {
      for (int x = 0; x < kMatrixWidth; x++) 
        {
        for (int y = 0; y < kMatrixHeight; y++) 
            {           
              fxdata.readBytes((char*)leds, NUM_LEDS*3);
              FastSPI_LED.show();
                delay(50); 
            }
        }
      }
   
  fxdata.close();

}

*****************************************************************************************************************************************************************

Header File

*****************************************************************************************************************************************************************

// Params for width and height
const uint8_t kMatrixWidth = 5;
const uint8_t kMatrixHeight = 5;

#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
CRGB leds[ NUM_LEDS ];

// This function will return the right 'led index number' for 
// a given set of X and Y coordinates on your RGB Shades. 
// This code, plus the supporting 80-byte table is much smaller 
// and much faster than trying to calculate the pixel ID with code.
#define LAST_VISIBLE_LED 10
uint8_t XY( uint8_t x, uint8_t y)
{
  // any out of bounds address maps to the first hidden pixel
  if( (x >= kMatrixWidth) || (y >= kMatrixHeight) ) {
    return (LAST_VISIBLE_LED + 1);
  }

  const uint8_t ShadesTable[] = {
//pixel Layout
// o o x o o
// o x x x o
// o x x x o
// o x x x o
// o o x o o


      11, 12, 0, 13, 14,
       16, 3, 2, 1, 15,
       17, 4, 5, 6, 18,
       20, 9, 8, 7, 19,
      21, 22, 10, 23, 24   

  };

  uint8_t i = (y * kMatrixWidth) + x;
  uint8_t j = ShadesTable[i];
  return j;
}

  Are you sure? yes | no

Wilbur Bacalso wrote 06/14/2016 at 22:16 point

I've tried changing the output options and none of them seems to transfer onto the myanim.dat file. Anyone manage to find a solution to this?

  Are you sure? yes | no

jens.andree wrote 06/14/2016 at 23:11 point

Is it glediator that is not exporting a data file for you? This project merely reads the previously recorded data stream from glediator that you put on an sdcard, thus making it a standalone solution. 

  Are you sure? yes | no

Wilbur Bacalso wrote 06/14/2016 at 23:48 point

Hey Jens. Thanks for the response. I'll tell you a little bit about my project. I'm using an Uno with a matrix of  10 x 15 WS2812b strips and an Adafruit micro sd breakout board. It's for an LED vest for a festival. I've recorded different animations and put them on the sd card. My Uno does read the file and plays the animation that I've recorded onto the matrix, but the layout and colour is incorrect. When I change any of the output options in Glediator, press apply, record another animation and transfer it onto the sd card, nothing I've changed in the output options affects the color or layout on my matrix. I'm using the Glediator with SD card sketch that you wrote.

  Are you sure? yes | no

jens.andree wrote 06/15/2016 at 19:48 point

Wilbur - the most common problem people have with Glediator and my script (not that my script has to do with any of this but anyway) is that they either have the order of the led strip segments wrong, or they have made the layout wrong (as in 15x10 instead of 10x15). 
Are your strips oriented LR-RL or LR-LR? (or something else?)
How have you configured the output in Glediator?
Also you can get really weird faults if you declare the wrong led strip type in the script. My example uses WS2801 so make sure you have the correct one when calling FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
Valid variants are LPD8806, WS2801, WS2803, SM16716, P9813, APA102 and DOTSTAR.

  Are you sure? yes | no

Wilbur Bacalso wrote 06/17/2016 at 00:25 point

I changed my matrix size from 10 x 15 to 15 x10 and changed my wiring from LRRL to LRLR. It's working now, but the only issue is that my animations are now turned 90 degrees and the color order is wrong. No biggie. Doesn't make much of a difference for most of the installed patterns. I've had to make adjustments to animated gifs and captured video, but otherwise works great. I've read that other people were also not able to save the output options. Still, cool software and my vest is looking really cool already! Thanks a lot for the help!

  Are you sure? yes | no

Zunaidcbz wrote 04/22/2016 at 07:11 point

#define CMD_NEW_DATA 1

#define BAUD_RATE 500000  //if using Glediator via serial 
what does these two line means???

  Are you sure? yes | no

jens.andree wrote 06/14/2016 at 23:08 point

The first define is used for certain LED strips and the BAUD_RATE is left over from the first version of the code that also allowed direct connection between computer and Arduino via USB, but since the whole purpose of this little hack was to make it standalone with an sdcard, that part eventually got removed.

  Are you sure? yes | no

Zunaidcbz wrote 04/22/2016 at 07:08 point

Sir....is there any need of connecting arduino with pc in glediator from sdcard arduino?? because you wrote serial() function in your sketch..?? Is arduino displays animation on adressable led matrix from sd card without any connection between pc and arduino?

  Are you sure? yes | no

daniel wrote 03/01/2016 at 22:40 point

Hi

i have tried this code and it works great.

but i have some basic questions regrading led strip layout

1. i have WS2811 strip, but there is a cheap every 3 led

my configuration is 12 horizontal strips of 69 led each

do i have to write in matrix size (glediator)

23, 12, 0  or 69,12,3  (3 is a apace parameter)

I have noticed a line in arduino code:

fxdata.readBytes((char*)leds, NUM_LEDS*3);

2. why i can't find  strip layout  in the code

(how strips are wired and where is the data in)

3. does output option in glediator matters if i use file from SD card?

Thanks

Daniel

  Are you sure? yes | no

jens.andree wrote 03/01/2016 at 23:00 point

Hi Daniel.

1) The arduino sketch takes no consideration to how the leds are arranged, this is all configured in Glediator so you only have to specify the total amount of leds in the sketch and you're done!

The *3 part in fxdata.readBytes() is just because you parse three values per loop (R+G+B or B+R+G depending on your setup) so don't alter that part - unless you're doing improvements or such ;)

2) Strip layout is done in Glediator - including how you've wired the strips LRLR or LRRL. 

I wrote the sketch in order to be as small as possible in order to make as much SRAM available for the maximum number of leds addressable as possible. All variables are stored in SRAM and many arduino only have 2K SRAM...

3) I'm not quite sure what you mean in question 3? I just enter the size of my display in Glediator and when I export to disk I make sure the ordering is correct, there are no other things to change if I remember correctly?

The output size of the file is very small but I tend to keep the files at a reasonable size - and I haven't yet tested with really big files, but I think it'll work as long as you remember that arduinos and similar have very little memory to play with.

I just saw that Glediator has received a few updates since I wrote Glediator from sdcard so shortly I shall have a look to see if there are any changes that should be implemented in my code as well?

Best Regards,

Jens

  Are you sure? yes | no

daniel wrote 03/02/2016 at 08:18 point

Thanks Andde

1. is LRLR mean "Left -Right Left- Right"?

So if i have a zigzag pattern starts at the bottom left side i need "LRRL?"

2. what about "1 cheap per 3 led" issue? my strips are not fully addressable.

i have a cheap every 3 leds not 1...

 so do i have to devide my led count by 3? i had to do it in led edit program...

  Are you sure? yes | no

jens.andree wrote 03/02/2016 at 08:37 point

1) Yes, you're correct on the order! My first display was made LRLR since I thought it'd be easier to program it that way but the cable management was a far bigger issue than code so nowadays I use as little cable as possible, i.e. zig-zag pattern.

2) Aha! Now I understand ;)

I haven't seen a LED strip with only a WS2811 chip per every third led (WS2812b?) because most people use 5050 type leds with a WS2811 embedded with every LED.

Have you got any example code from where you bought it where you can individually address each LED? It could be timing based like the older LED strips?

The FastLED library that I'm using implements most popular LED strips and I don't know if this perhaps can be resolved whilst setting up the LED strip in the code?

Sorry but this is unknown to me so it's hard to give any recommendations since I have nothing to test with. If you have example code that works - i.e. you can write to every LED in some other way than one by one, then have a look at that and see if it can be adapted?

You can try to divide the LED count by 3 in Glediator on the X axis and see if that helps?

Best Regards and good luck!

Jens

  Are you sure? yes | no

JoyMonkey wrote 09/15/2015 at 11:49 point

I build custom LED boards for the R2 Builders Club and also wire my LED rows in a  serpentine order (this makes routing the wires on the PCB much simpler). To get around this in my Arduino sketches I define/map the pixel order using an array at the start of the sketch, then refer the LEDs using that array instead of the actual LED order. See line 99 of this horrible old sketch... https://github.com/joymonkey/logicengine/blob/master/old_sketches/LogicEngineBasic7c/LogicEngineBasic7c.ino
I'm not using Glediator yet, but will definitely give it  a try soon along with Jens' awesome Arduino sketch.

  Are you sure? yes | no

Mannymiller wrote 07/16/2015 at 14:47 point

That's what it looks like to me too.. But changing hstl to vsbr should at least change the flow direction of the scrolling text., but does not. I have been using jinx without a problem. Just loved your idea of running from an sd card instead of a pc. Will have to look into it further. Thanks for your help. 

  Are you sure? yes | no

Mannymiller wrote 07/16/2015 at 14:10 point

Hi, thanks for your reply. I have done exactly that. I have tried all of the layouts. None of them seem to change the output. I am using hstl, which I assume is horizontal snake, top left as my output. Matrix size of 16x16 as its a one colour scrolling text, Rgb, or Grb will make no difference. This gives me a scrambled out put. I have also tried most of the other output variants too. Which makes no effect to whats displayed when myanim.dat Is played. I will look into it further later.

  Are you sure? yes | no

jens.andree wrote 07/16/2015 at 14:19 point

Sadly it's not me who's written Glediator, I'm just a tinkerer who use it and the config isn't exactly crystal clear imho, but if you had the setup you described in your first comment then all you need to do is to change the direction of every second line and you should be fine!

  Are you sure? yes | no

jens.andree wrote 07/16/2015 at 09:41 point

In the Glediator application you have to specify how the leds are arranged, this is controlled in Output Options->Pixel Order. 

  Are you sure? yes | no

Mannymiller wrote 07/16/2015 at 07:41 point

Great idea. I'm using a mega, and 16x16 ws2812b matrix. On playback a simple text scroll I'm getting lines 1,3,5 scroll from left to centre. And lines 2,4,6 scroll from right to centre. I have the matrix set correct in glediator. Horizontal snakes lines top left, have tried all the others which doesn't seem to change anything. Any ideas?

  Are you sure? yes | no

alex gorbatchev wrote 08/22/2015 at 03:40 point

I'm seeing the same results. I have a feeling that pixel order isn't respected in recording mode.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates