How to use a LED Matrix with FEZ Panda II?

I recently purchased a FEZ Panda II + Ethernet/Connector Shield. I also purchased a couple LED Matrix components from SparkFun:
http://www.sparkfun.com/products/759

Now I need to learn how to make the two things work together. Ive been thinking about using a breadboard to plug the LED Matrix in, and then wire it up to the FEZ Connect shield. Can some provide a little guidance on how exactly I should go about this? Best practices? Things to avoid, etc?

Thanks, Paul

We have this already used on one of the demos. Let me see if I can dig the code for you.

@ Gus, That would be great. I noticed SparkFun posted some sample code, but it’s all in C, not C#. This raises another question: is it possible to somehow compile C into an assembly, then disassble into C# - or something like that?

The problem I’ve been running into with SparkFun is that all the code samples they post are in C, probably for Arduino platform. Got any tricks to convert that stuff to C# - generally speaking?

Thanks, Paul

The code is too simple to go though all this trouble! Way too simple :slight_smile:

A driver for this LED matrix:

[url]http://code.tinyclr.com/project/327/sparkfun-led-matrix/[/url]

@ Joe Thanks for the pointer to source code. I’m trying that now, but nothing is displaying on my LED Matrix. There are 6 pins on the SPI Input interface, as follows:

VCC = I have this hooked to 5 volt.
VCC
SCLK
CS = I have this hooked to Digital Input 1.
MISO
GND = I have this hooked to ground.

I’ve got the following code running in my Main method:

        using ( var spiBus =
                new SPI(new SPI.Configuration(Cpu.Pin.GPIO_NONE, false, 0, 0, false, false, 1000,
                                              SPI.SPI_module.SPI1)))
        {
            var panel1 = new SparkfunLEDMatrix((Cpu.Pin)FEZ_Pin.Digital.Di1, spiBus);
          
            for (var i = 0; i < numbersBitmap.Length; i++)
            {
                panel1.Write64ByteToDisplay(numbersBitmap[i]);
                Debug.Print(i + ": " + numbersBitmap[i].Length);
                Thread.Sleep(1000);
                if (i >= numbersBitmap.Length - 1) i = 0; // Display 0, 1, 2 forever
            }
        }

Any ideas why nothing is showing? I know the LED Matrix is good because when I unplug then replug the ground wire, it flashes.

Whee so you connect the SPI pins?!

@ Gus - Forgive me for my ignorance, but what exactly are the SPI pins? And where would I find them on the FEZ Panda II, specifically on the Connect Shield?

First, search the web for SPI to learn more about it then take a look at SPI tutorial on this page

Then change your pins to

VCC = I have this hooked to 5 volt.
VCC
SCLK = SCK on your FEZ <<<<<<<<
CS = I have this hooked to Digital Input 1.
MISO = MISO on your FEZ <<<<<<<<<
GND = I have this hooked to ground.

note that you have 2 SPI channels so you can use either one but the code has to reflect which one you use

@ Gus Thanks I have it working now! It started working after I plugged the MOSI in. I didn’t realize I needed to look at the FEZ base board, instead of the Connect Shield. You must love beginners :slight_smile:

Today’s beginners the are future experts…we hope you stick around and help future beginners :slight_smile:

OK, another related question about the LED Matrix. I have two of these daisy chained together. They are both displaying exactly the same thing (numbers iterating). How do I control each of these separately? Do I need to set up a different SPI Bus, or something like that?

Basically I want to move lights from one display to the next, but currently the displays are just duplicates of each other.

Did you read on SPI? :slight_smile:

Use same bus but different chipselect

basically you have two devices (well actually it can be any # of multiple) , each with their own CS line as Gus says. You need to manage the bit-rotation from one to the next. So it could be something as simple as:

fill your buffer with text (or representation of text)
while(somecheck that buffer isn’t empty)
{
set CS to first display
write it’s value
disable CS to first
set CS to 2nd display
write it’s value
disable CS
wait for your character dwell time
shift your display’s values
}