Introduction: Arduino 8x8 Matrix Mad Eyes

About: I build therefore I am.

This was something that I started for my son. He is now into bikes and skating so I suggested getting him an old helmet to prevent him messing up his hair while trying out the stunts he has seen the other kids do.

Anyhow, the idea was to make his helmet something special, so this was my Mad Eyes that I was thinking of putting into the helmet.
I am just waiting to find a suitable one to mod where the modding won't detract from the integrity. Or I suppose the most important thing here should be - should not stop him frm seeing where he was going!

That aside I have read up on a few methods to control 8x8 matrix and the more simple the better in my case!

So I decided to use a MAX7219 chip and the Arduino Uno ATmega328.

Step 1: Mad Eye Parts

For this little adventure you will need

MAX7219 chip ( I got mine from eBay)
01. uF capacitor
ATMega328 (or an UNO)
8x8 LED matrix (again, eBay)
a limiting resistor depending on your marrix
5V DC Power supply (you'll never guess, eBay!)

I get a lot of info from the Arduino.cc web site, they have all the info you could possibly need if you know where to look.

Although there is no capacitor shown on the schematic it should have a suppression capacitor of around 0.1 uF as close to the MAX chip as possible. Most instructables also mention this although the value does seem to change from one to another.




Step 2: Understanding the Matrix Neo

The matrix confused me to start with but it is quite simple once you get your head around it.
Once you realize that the pins don't simply go from 1 to 8 on the top and the same on the bottom. Basically they are all over the place!

The first step is to map the matrix using a suitable power source and a limiting resister. It is all trial and error so start by sticking it onto some pins and see which LED lights up, then make a note. Then try moving one wire to another pin and so on.....
I looked for data sheets on the net but the pin layout was different so I started from scratch.

The MAX7219 chip takes data in the form of (in this case) maxAll(1,126); maxAll means that with the code I am usingt will send the same data to all MAX7219 chips if they are cascaded, data out from the first to data in on the second and third etc.

On an 8 x 8 matrix the LED's are defined as rows which are (with the matrix in the orientation I have them)
Seg DP to G on the MAX chip and columns which are Dig 0 to 7.

So, the rows are noted as DP, A, B, C, D, E, F, G
The columns are noted as 0, 1, 2, 3, 4, 5, 6, 7
Simple so far :)
When you address something on the display you need the column and the rows address, each row has a numeric value:

1, 2, 4, 8, 16, 32, 64 and 128
So if you only wanted the first LED on you have maxAll(1,1);
Row 1 and LED 1 On
if you want more than 1 LED on on a specific row you need to add up the individual numbers, so to get every other LED on you would add 1, 4, 16, 64 giving a total of 85
maxAll(1,85);

Step 3: The Layout of Code

The code is taken from the MAX7219 demo code from Arduino.cc then simply added a couple of random states for the action and the delay duration.

I have only added 7 eye states at the moment, although the blink has 4 seporate states in Action 5, but all you need to do to add another one is copy the following code:

if (Action == 4) {

   maxAll(1,126);        //  - + + + + + + -
   maxAll(2,255);        //  + + + + + + + +
   maxAll(3,159);        //  + + + + + - - +
   maxAll(4,159);        //  + + + + + - - +
   maxAll(5,255);        //  + + + + + + + +
   maxAll(6,255);        //  + + + + + + + +
   maxAll(7,255);        //  + + + + + + + +
   maxAll(8,126);        //  - + + + + + + -

  delay(RandDelay);
  }

insert that somewhere in the void loop and change the Seg section to resemble the display you want. Then change the Action == 4 to the next number in the line and also the variable in the
Action = random(7);
to the amount you have in total, so if you are adding one more eye position just change it to
Action = random(8);
and so on.

The full code is at the bottom of the page on the link, once you have installed that on to the editor you can have a play with the image. I have included a layout in the code of how each segment should display on the matrix, it helps when you try and set the values. 

This is a YouTube video test.

Step 4: Wiring!

This looks a lot harder than it actually is as there are so many wires involved.
I have done a schematic that shows it wire for wire, as mentioned before this does not include the 0.1 uF capacitor.

Once that is all done you should have a set of random animated eyes watching your every step :-)

If anyone does try this out I would love to know what you end up doing with them, I have a plan for a set of these and I will post some pictures at a later date.

Enjoy!

Update:

I have noticed one slight mistake on the schematic, it is one of the connections is slightly too short, now noted on the image.

The other thing is that my UNO was only pumping out 3.8V on the 5V line, when you put the full 5V on to the MAX7219 chip it gets rather hot. So, I reduced the voltage and all is OK again.

Step 5: Files in All Formats

This is just the different files in image and PDF forms if you need more clarity.