Cheap Max7219 Chainable LED Matrix

August 13, 2015 at 10:53 pm (computers) (, , , , )

I can’t resist a cheap LED matrix, so when I stumbled across these 8×8 LED matrix displays with a Max7219 driver LED in this chainable form-factor for, get this, less than £1.50 each from electrodragon.com … well, I had to give them a go.  It is a relatively simple circuit board to build, so there are very minimal instructions, but there are still a couple of gotchas that might catch out a beginner, so I’ve put together these notes whilst putting them together.  By the way, I ordered 9 so I could eventually form a 24×24 LED square (3×3 of the matrices).

2015-08-07 13.06.582015-08-07 13.07.22

I started with the headers, then the discrete components, finally the chip.  The only thing to note is the polarity of the electrolytic capacitor (of course – look for the + on the circuit board) and the orientation of the chip itself.  Also note that ‘pin 1’ of the LED matrix sockets are indicated by a square pad in the top right of the circuit board (as seen from the top, with the writing the right way up).  It is worth fiddling with the electrolytic prior to soldering to try to ensure it doesn’t poke out over the top edge of the circuit board – although if it does, if physically mounting boards next to each other, it will quite happily overlap into the next board.

The design suggests that all the header pins face upwards and that the jumpers are used on the top of the board to chain them together.  however, I didn’t really want to have to take off the LED matrix every time I wanted to change how it was linked, so I opted to solder the connecting header pins to the underside of the board as shown.  It also gets around the issue they describe on the product webpage about the LED matrix not really fitting snugly on the board.  Mine fits nice and tight.

2015-08-07 17.44.28-sm

So all that remains is to add the LED matrix.  As I said, pin 1 should be indicated on the matrix itself and is indicated on the circuit board by the square pad near the electrolytic capacitor.

In terms of making the thing work, it is relatively simple to connect up:

  • CLK – D2
  • LD – D3
  • DIN – D4
  • VCC – VCC
  • GND – GND

Of course when chaining with jumpers DOUT goes to the next LED DIN.  The other pins pair up.

There is a lot of arduino code for these types of driver chips – start here – http://playground.arduino.cc/Main/LEDMatrix.

I used the code from here to test my setup – http://playground.arduino.cc/LEDMatrix/Max7219 – as written this assumes the same pinouts as I describe above (i.e. CLK, LD, DIN on digital pins 2, 3 and 4).

You just need to set the number of chained displays at the top:

int maxInUse = 9;

(in my case) and get to work playing.  The routines in the library provide a simple interface to setting rows on a single or all of the chained displays.  maxSingle is meant for when there is just one display.  maxAll displays the same value on all displays in the chain.  maxOne will target a specific display (starting with display number 1 up to your last – 9 in my case).

2015-08-08 16.02.16-sm

As you can perhaps see, this is using an Ardunio nano.  With 9 boards cascaded, getting the PC to recognise the nano was plugged in was sometimes a problem – it often gave me a ‘there is a problem with your USB device’ error on Windows 7.  It was fine with lesser numbers of matrices, so I guess there is a power issue with the nano struggling with the USB setup and initialising all 9 LED matrices at the same time.  Temporarily disconnecting VCC from the LEDs when plugging in the USB seems to solve the issue for me.

As I eventually want to be setting an entire row of LEDs in a larger grid, the maxOne function is a little wasteful as it has to shunt null values to all of the LED displays you are not targeting – so calling it 9 times means writing 81 bytes out across the DIN pin just to actually set 9 bytes.  Consequently it is possible to optimise it a little if you want to write an entire row to all displays in the same transaction.

Of course, if you refer back to the LedMatrix page, there are many other libraries that will do most of this for you, including Marco’s very complete library for scrolling text displays – http://parola.codeplex.com/ – but I quite like being able to see what the low-level code is actually doing to make things work.

I’ve therefore added a maxRow function as follows:

// Note: Sloppy code warning!
// There is no checking here that *col is an array of
// the correct length - i.e. maxInUse
//
// It should be defined and used as follows:
//    byte row[maxInUse];
//    // fill each byte of row with your data - row[0], row[1], row[2], etc.
//    // using one byte for each matrix in sequence
//    maxRow (1, &row[0]);
//
void maxRow (byte reg, byte *col) {
  int c=0;
  digitalWrite(load,LOW);
  for (c=maxInUse; c>=1; c--) {
    putByte(reg);
    putByte(col[c-1]);
  }
  digitalWrite(load,LOW);
  digitalWrite(load,HIGH);
}

But I haven’t mentioned the absolutely best feature of these little boards yet.  And that is that they are almost exactly the same dimension as a 4-stud Lego brick.  This means it was trivial to make a simple enclosure to hold my 3×3 grid and the nano.

2015-08-10 21.12.11 2015-08-10 21.12.04

I now have a really cool game-of-life running on my 24×24 LED grid.  At this price, I have another 8 on order so I can take it to a 4×4 grid (with one spare).

Kevin

Advertisements

Permalink Leave a Comment

Sorting Lego

February 25, 2012 at 3:50 pm (interesting, kids, odds) (, , , )

Lego.  Can you have too much?  Possibly.  It appears at least to be a question that my family is slowly attepting to answer …

Of course past a certain critical mass, you get to the point where it is almost impossible to build anything, as you have just too much to sort through to find a piece.  Couple this with the trend for increasingly specialised parts in a much wider range of colours and you get to the point where you know you have the part in question, but you also know its just one or two of … well … quite a lot, so you tend to give up before you even start.

Hence sorting Lego is kind of mandatory.  But it takes a long time and when all is said and done you are basically attempting to reduce disorder and chaos (and everyone knows how fruitful that is!)

So what do to … can Google help?  Hmm, maybe.  Here are some examples.

This shows some promise – it sorts based on size and shape.  It seems quite accurate too.  But it is very slow! At this rate bricks would never be sorted faster than they were used, so this really isn’t likely to solve the issue.

This ones a little faster, but doesn’t look like it has a huge range of bricks it recognises.  Still sorts on shape and colour – thats quite impressive.

Now the concept behind this one shows some promise.  Its not sorting lego, just beads presumably based on colour, but it looks like the kind of design that might scale up.

This is probably the most comprehensive one I’ve seen yet – but with 7 NXTs, 28 motors and 37500 bricks … well, it still only really sorts a subset of bricks.  Still its quite amazing to watch.

But you know what?  This one is just a work of art.  One motor.  No programmable brick.  Just cogs, gears, differentials and bands … its the kind of creation that one just stares at in wonderment.  By far the simplest, most elegant lego creation I’ve seen in a long time.  So what if it only sorts 2 by something bricks.  So what that it only sorts on length.  So what that you have to align bricks to load it.  This is pure lego mastery.

So.  Can anyone do better? Or are we doomed to resorting to trained chimps (sorting monkeys?) and bribed children?

Kevin.

Permalink Leave a Comment

World of Legocraft

January 10, 2010 at 10:40 pm (internet, kids) (, , , , , , , , , )

Have just seen the trailer for the new Lego Universe virtual world. I’ve heard various things about it over the last 18 months or so, but the final form seems to be some kind of Lego MMO, a Lego version of World of Warcraft if you will, with customisable characters, quests, building, levels and so on. You will also have to pay for it by a monthly subscription. I had assumed it would be more along the lines of, say, Disney’s Pixie Hollow or a Lego version of Habbo Hotal, but it looks much more a gamey than social virtual world.

The trailer is very impressive, but as its a digital film, it doesn’t really give anything away about the actual game.

Still, looks like it will keep Lego fans old and young busy for some time.  For more info, see Wikipedia and www.legouniverse.com.

Nod to Tervicz for the link to the video.

Kevin.

Permalink Leave a Comment

3D Internet Shopping

October 7, 2009 at 9:52 pm (computers, internet) (, , , , , , , , )

I’ve mentioned the 3D virtual side of the Lego shop before.  Well some people will tell you that the future of the Internet lies with 3D.  Forget Web 2.0, go Web 3D!

Well Lenovo, the PC manufacturer who took over the IBM laptop business, have created a 3D virtual shop where you can ‘go in’ and browse their laptop range, walk up to and communicate with sales assistents, take a friend in with you, and so on.  All you need to do is go to their ‘elounge’ website, download a plug-in, learn a few basic commands and off you go.

There are a number of people I’ve spoken to that say they would never use such a system, but my view is that if the whole idea of 3D virtual worlds loses some of its clunkiness, and sites like Amazon or Ebay were just using the technology, then people would just use it, just because that’s the way things are.

People didn’t conciously choose to use the web to get to Amazon or Ebay, these companies just used the default technology available, and made it as painless as possible for consumers to use the sites.  If they decided that 3D virtual worlds was the way to go, because it was a differentiator, enabled more sales or for whatever other reason, and the technology was mature enough to enable them to make it painless for consumers, then people would probably just get in and use it.  I am always amazed at how popular the cartoony virtual world games, like YoVille and FarmVille, are on Facebook.

The issue right now as I see things, is that the technology isn’t quite there yet.  Well, maybe experiments like the Lenovo eLounge are starting to lay the groundwork for the tech to catch up.

Kevin.

Lenovo.com eLounge

Lenovo.com eLounge

Permalink Leave a Comment

What to do with grey Lego

October 1, 2009 at 4:55 pm (art, kids, odds) (, , , )

Ever wonder what to do with small, grey lego bricks?  No?  Well, you should!  This guy has a great idea – use them to create walls worthy of the most expensive Sci-fi film set.  Oh, and if you have a few small coloured parts too, then how about a robot or two?

The design of these walls and robots is great.  Very creative use of Lego to very good effect.

Kevin.

Lego Walls and Robots

Lego Walls and Robots

Permalink Leave a Comment

Augmented Reality in the Lego Shops!

August 13, 2009 at 7:45 pm (interesting, kids) (, )

This is super cool!  I am reliably informed that the Lego Shop in Milton Keynes has one of these new flashy augmented reality picture booth things.

augmented reality with LEGO

See one in action here. Got to be worth a visit to see these (and I haven’t been in the Lego shop for ages)!

Kevin.

Permalink 1 Comment

The Muppet Matrix

August 16, 2008 at 9:13 pm (interesting, odds) (, , , , , )

I’ve seen loads of spoofs of major films. I particularly like some of the lego ones. However, I’ve probably just come across one of the funniest, The Muppet Matrix. This is a real classic. Almost as good as the ASCII art star wars saga

Kevin.

Permalink 1 Comment

Serious Lego …

April 10, 2008 at 5:29 pm (kids, odds) (, )

Now this is serious lego building. I just wonder where he gets his bricks from!

His brooklyn bridge is particularly fantastic.

Kevin.

Permalink Leave a Comment

Lego in landfill sites

October 28, 2007 at 11:00 am (house, interesting, kids) (, , , , , )

Whilst vacuuming the other day, i heard the tell-tale clattery noise that informed me that another piece of Lego had just started its journey to our local landfill site. Lego has such a distinctive noise when you buy it in a box, when you are sorting it and yes, even when it goes up the tube!

It did get me wondering how much Lego there must be in landfills around the world … we must vacuum up the equivalent of a set every few years just in our family. Of course its always the smallest bits, which never used to be an issue when there were only handful of colours but these days with new sets including new shades and sizes of bricks sometimes you end up with a very small number of the right colour of the right brick for that favourite model …

I also wondered (it takes a while to vacuum the hall in our house) what else you would find that has accidentally found its way to the landfill. Reached for google to see if anyone had anything about interesting finds from rubbish sites, but couldn’t find anything really. Lots about effects of landfill sites on health, about the toxic substances that are dumped, about disposable nappies and so on, but nothing about people finding anything interesting. If anyone comes across anything, do let me know.

I can’t believe no one has studied the important question of how much Lego gets thrown away each year 🙂

Kevin.

Permalink Leave a Comment